* @throws TwitterException when provided string is not a valid JSON string.
* @since Twitter4J 2.1.9
*/
public static Object createObject(String rawJSON) throws TwitterException {
try {
JSONObject json = new JSONObject(rawJSON);
JSONObjectType jsonObjectType = JSONObjectType.determine(json);
if (JSONObjectType.SENDER == jsonObjectType) {
return registerJSONObject(directMessageConstructor.newInstance(json.getJSONObject("direct_message")), json);
} else if (JSONObjectType.STATUS == jsonObjectType) {
return registerJSONObject(statusConstructor.newInstance(json), json);
} else if (JSONObjectType.DIRECT_MESSAGE == jsonObjectType) {
return registerJSONObject(directMessageConstructor.newInstance(json.getJSONObject("direct_message")), json);
} else if (JSONObjectType.DELETE == jsonObjectType) {
return registerJSONObject(statusDeletionNoticeConstructor.newInstance(json.getJSONObject("delete").getJSONObject("status")), json);
} else if (JSONObjectType.LIMIT == jsonObjectType) {
// TODO: Perhaps there should be a TrackLimitationNotice object?
// The onTrackLimitationNotice method could take that as an arg.
return json;
} else if (JSONObjectType.SCRUB_GEO == jsonObjectType) {