Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Using JSON APIs In Notes
public class JSONDemo {
private String myJsonString;
/**
* Constructor
* @param myJsonString a string representation of JSON
*/
public JSONDemo(String myJsonString) {
this.myJsonString = myJsonString;
}
/*
* Gets a Java object which you can use to get values from the JSON.
* @return a Java object which you can use to get values from the JSON
*/
public JsonJavaObject getJson() {
try {
//Use the extended instance so we can get back a JsonJavaObject from JsonParser
JsonFactory jsonFactory = JsonJavaFactory.instanceEx;
Object obj = JsonParser.fromJson(jsonFactory, myJsonString);
if(obj instanceof JsonJavaObject){
JsonJavaObject jsonObject = (JsonJavaObject)obj;
return jsonObject
}
} catch (JsonException e) {
e.printStackTrace();
} catch (TokenMgrError e){
e.printStackTrace();
}
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.