I have a tweet that I had stored in a file. I want to extract the user as a json object and store it in a different file. The following results in java.lang.IllegalStateException: Apparently jsonStoreEnabled is not set to true.
String jsonStatus; //Content read from a file
Status status = TwitterObjectFactory.createStatus(jsonStatus); //no problem here
String jsonUser = TwitterObjectFactory.getRawJSON(status.getUser()); //Exception
How can I set jsonStoreEnabled
to true
? Or, is there another way of doing it? I don't have to stick with Twitter4j
to create jsonUser
. I tried json-simple
, but the resulting String is not parsable with Twitter4j.
It turns out that the org.json
package was helpful in this case:
public static String extractUser(String rawJSON) {
return new org.json.JSONObject(rawJSON).get("user").toString();
}