List of usage examples for org.json.simple JSONObject getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:TestJSONStringBuffer.java
public void testObjectInObject() { try {/* www . j ava 2 s. c o m*/ JSONStringBuffer buf = new JSONStringBuffer(); buf.append(objectInObject[0]); assertEquals(false, buf.stringsAvailable()); buf.append(objectInObject[1]); assertEquals(false, buf.stringsAvailable()); buf.append(objectInObject[2]); assertEquals(true, buf.stringsAvailable()); ArrayList<String> strings = buf.retrieveAvailableStrings(); assertEquals(1, strings.size()); Object o = new Decoder().decode(strings.get(0)); assertNotNull(o); assertEquals(JSONObject.class, o.getClass()); JSONObject obj1 = (JSONObject) ((JSONObject) o).get("obj1"); assertEquals(JSONObject.class, obj1.getClass()); JSONObject obj2 = (JSONObject) obj1.get("obj2"); assertEquals(JSONObject.class, obj2.getClass()); Long obj3 = (Long) obj2.get("obj3"); assertEquals(Long.class, obj3.getClass()); assertEquals(new Long(42), obj3); } catch (Exception e) { System.err.println(e); fail(); } }