@Test public final void testDecodeObject4() { JSONDecoder decoder = new JSONDecoder("{\"key\":\"value\",\"key2\":{\"key3\":\"value2\"},\"key5\":true}"); JSONObject result = (JSONObject)decoder.decode(); Map<String, JSONValue> value = result.getValue(); Assert.assertEquals("{\"key3\":\"value2\"}", value.get("key2").toJSON()); Assert.assertEquals("true", value.get("key5").toJSON()); Assert.assertEquals("\"value\"", value.get("key").toJSON()); }
public JSONValue decode() { char current = reader.current(); if(current == Opener.OBJECT.sign) { return decodeObject(); } else if(current == Opener.STRING.sign) { return decodeString(); } else if(current == Opener.ARRAY.sign) { return decodeArray(); } else if( Character.isDigit(current) || current == Opener.MINUS.sign || current == Opener.PLUS.sign || current == Opener.DOT.sign) { return decodeNumber(); } else if( current == Opener.NULL.sign || current == Opener.NULL_UPPER.sign) { return decodeNull(); } else if( current == Opener.FALSE.sign || current == Opener.FALSE_UPPER.sign) { return decodeFalse(); } else if( current == Opener.TRUE.sign || current == Opener.TRUE_UPPER.sign) { return decodeTrue(); } return null; }
JSONDecoder { public JSONValue decode() { char current = reader.current(); if(current == Opener.OBJECT.sign) { return decodeObject(); } else if(current == Opener.STRING.sign) { return decodeString(); } else if(current == Opener.ARRAY.sign) { return decodeArray(); } else if( Character.isDigit(current) || current == Opener.MINUS.sign || current == Opener.PLUS.sign || current == Opener.DOT.sign) { return decodeNumber(); } else if( current == Opener.NULL.sign || current == Opener.NULL_UPPER.sign) { return decodeNull(); } else if( current == Opener.FALSE.sign || current == Opener.FALSE_UPPER.sign) { return decodeFalse(); } else if( current == Opener.TRUE.sign || current == Opener.TRUE_UPPER.sign) { return decodeTrue(); } return null; } }
JSONDecoder { public JSONValue decode() { char current = reader.current(); if(current == Opener.OBJECT.sign) { return decodeObject(); } else if(current == Opener.STRING.sign) { return decodeString(); } else if(current == Opener.ARRAY.sign) { return decodeArray(); } else if( Character.isDigit(current) || current == Opener.MINUS.sign || current == Opener.PLUS.sign || current == Opener.DOT.sign) { return decodeNumber(); } else if( current == Opener.NULL.sign || current == Opener.NULL_UPPER.sign) { return decodeNull(); } else if( current == Opener.FALSE.sign || current == Opener.FALSE_UPPER.sign) { return decodeFalse(); } else if( current == Opener.TRUE.sign || current == Opener.TRUE_UPPER.sign) { return decodeTrue(); } return null; } JSONDecoder(final String json); }
JSONDecoder { public JSONValue decode() { char current = reader.current(); if(current == Opener.OBJECT.sign) { return decodeObject(); } else if(current == Opener.STRING.sign) { return decodeString(); } else if(current == Opener.ARRAY.sign) { return decodeArray(); } else if( Character.isDigit(current) || current == Opener.MINUS.sign || current == Opener.PLUS.sign || current == Opener.DOT.sign) { return decodeNumber(); } else if( current == Opener.NULL.sign || current == Opener.NULL_UPPER.sign) { return decodeNull(); } else if( current == Opener.FALSE.sign || current == Opener.FALSE_UPPER.sign) { return decodeFalse(); } else if( current == Opener.TRUE.sign || current == Opener.TRUE_UPPER.sign) { return decodeTrue(); } return null; } JSONDecoder(final String json); JSONValue decode(); }
JSONDecoder { public JSONValue decode() { char current = reader.current(); if(current == Opener.OBJECT.sign) { return decodeObject(); } else if(current == Opener.STRING.sign) { return decodeString(); } else if(current == Opener.ARRAY.sign) { return decodeArray(); } else if( Character.isDigit(current) || current == Opener.MINUS.sign || current == Opener.PLUS.sign || current == Opener.DOT.sign) { return decodeNumber(); } else if( current == Opener.NULL.sign || current == Opener.NULL_UPPER.sign) { return decodeNull(); } else if( current == Opener.FALSE.sign || current == Opener.FALSE_UPPER.sign) { return decodeFalse(); } else if( current == Opener.TRUE.sign || current == Opener.TRUE_UPPER.sign) { return decodeTrue(); } return null; } JSONDecoder(final String json); JSONValue decode();  }