@Test public final void testDecodeObject() { JSONDecoder decoder = new JSONDecoder("{\"key\":\"value\"}"); JSONValue result = decoder.decode(); TestCase.assertEquals("{\"key\":\"value\"}", result.toJSON()); }
private JSONObject decodeObject() { JSONObject result = new JSONObject(); boolean hasNext = true; while(hasNext) { reader.next(); if(reader.current() == Closer.jsonobject.sign) { hasNext = false; return result; } JSONString key = decodeString(); while(reader.next()) { char temp = reader.current(); if(temp == ':') { reader.next(); break; } } JSONValue value = decode(); result.put(key.toString(), value); reader.next(); if(reader.current() == Closer.jsonobject.sign) { hasNext = false; } } return result; }
JSONDecoder { private JSONObject decodeObject() { JSONObject result = new JSONObject(); boolean hasNext = true; while(hasNext) { reader.next(); if(reader.current() == Closer.jsonobject.sign) { hasNext = false; return result; } JSONString key = decodeString(); while(reader.next()) { char temp = reader.current(); if(temp == ':') { reader.next(); break; } } JSONValue value = decode(); result.put(key.toString(), value); reader.next(); if(reader.current() == Closer.jsonobject.sign) { hasNext = false; } } return result; } }
JSONDecoder { private JSONObject decodeObject() { JSONObject result = new JSONObject(); boolean hasNext = true; while(hasNext) { reader.next(); if(reader.current() == Closer.jsonobject.sign) { hasNext = false; return result; } JSONString key = decodeString(); while(reader.next()) { char temp = reader.current(); if(temp == ':') { reader.next(); break; } } JSONValue value = decode(); result.put(key.toString(), value); reader.next(); if(reader.current() == Closer.jsonobject.sign) { hasNext = false; } } return result; } JSONDecoder(final String json); }
JSONDecoder { private JSONObject decodeObject() { JSONObject result = new JSONObject(); boolean hasNext = true; while(hasNext) { reader.next(); if(reader.current() == Closer.jsonobject.sign) { hasNext = false; return result; } JSONString key = decodeString(); while(reader.next()) { char temp = reader.current(); if(temp == ':') { reader.next(); break; } } JSONValue value = decode(); result.put(key.toString(), value); reader.next(); if(reader.current() == Closer.jsonobject.sign) { hasNext = false; } } return result; } JSONDecoder(final String json); JSONValue decode(); }
JSONDecoder { private JSONObject decodeObject() { JSONObject result = new JSONObject(); boolean hasNext = true; while(hasNext) { reader.next(); if(reader.current() == Closer.jsonobject.sign) { hasNext = false; return result; } JSONString key = decodeString(); while(reader.next()) { char temp = reader.current(); if(temp == ':') { reader.next(); break; } } JSONValue value = decode(); result.put(key.toString(), value); reader.next(); if(reader.current() == Closer.jsonobject.sign) { hasNext = false; } } return result; } JSONDecoder(final String json); JSONValue decode();  }