To parse a document from a string to a JsonObject:
JsonObject json = JsonObject.parse("{a:3, b:'hello world'}");
To generate a json string from a JsonObject:
System.out.println(json.toString);
To generate a json string from a JsonObject - pretty print with 2 spaces for tabs:
System.out.println(json.toString(2));
To read ints/strings, etc:
String b = json.getString("b");
int a = json.getInt("a");
JsonObjects rarely need exception handling, instead of throwing an exception if fields aren't set, nulls or 0's are returned, but if you care to check, you can:
String b = "...";
if (json.isString("b")) b = json.getString("b");