@Test public final void testDecodeArray() { String orig = "[\"key\",\"key2\"]"; JSONDecoder decoder = new JSONDecoder(orig); JSONValue result = decoder.decode(); TestCase.assertEquals(orig, result.toJSON()); }
private JSONArray decodeArray() { JSONArray result = new JSONArray(); boolean hasNext = true; while(hasNext) { reader.next(); if(reader.current() == Closer.jsonarray.sign) { hasNext = false; return result; } JSONValue value = decode(); result.add(value); if(reader.current() == Closer.jsonarray.sign) { hasNext = false; } reader.next(); if(reader.current() == Closer.jsonarray.sign) { hasNext = false; } } return result; }
JSONDecoder { private JSONArray decodeArray() { JSONArray result = new JSONArray(); boolean hasNext = true; while(hasNext) { reader.next(); if(reader.current() == Closer.jsonarray.sign) { hasNext = false; return result; } JSONValue value = decode(); result.add(value); if(reader.current() == Closer.jsonarray.sign) { hasNext = false; } reader.next(); if(reader.current() == Closer.jsonarray.sign) { hasNext = false; } } return result; } }
JSONDecoder { private JSONArray decodeArray() { JSONArray result = new JSONArray(); boolean hasNext = true; while(hasNext) { reader.next(); if(reader.current() == Closer.jsonarray.sign) { hasNext = false; return result; } JSONValue value = decode(); result.add(value); if(reader.current() == Closer.jsonarray.sign) { hasNext = false; } reader.next(); if(reader.current() == Closer.jsonarray.sign) { hasNext = false; } } return result; } JSONDecoder(final String json); }
JSONDecoder { private JSONArray decodeArray() { JSONArray result = new JSONArray(); boolean hasNext = true; while(hasNext) { reader.next(); if(reader.current() == Closer.jsonarray.sign) { hasNext = false; return result; } JSONValue value = decode(); result.add(value); if(reader.current() == Closer.jsonarray.sign) { hasNext = false; } reader.next(); if(reader.current() == Closer.jsonarray.sign) { hasNext = false; } } return result; } JSONDecoder(final String json); JSONValue decode(); }
JSONDecoder { private JSONArray decodeArray() { JSONArray result = new JSONArray(); boolean hasNext = true; while(hasNext) { reader.next(); if(reader.current() == Closer.jsonarray.sign) { hasNext = false; return result; } JSONValue value = decode(); result.add(value); if(reader.current() == Closer.jsonarray.sign) { hasNext = false; } reader.next(); if(reader.current() == Closer.jsonarray.sign) { hasNext = false; } } return result; } JSONDecoder(final String json); JSONValue decode();  }