@Test public void embedded() throws IOException { String obj = "{\"authors\":[\"Ted\", \"Mark\"],\"date\": {\"year\":2013,\"month\":9}}"; JsonLexer l = new JsonLexer(new StringReader(obj)); JsonParser p = new JsonParser(l); Map<String, Object> m = p.parseObject(); assertEquals(2, m.size()); @SuppressWarnings("unchecked") List<String> authors = (List<String>)m.get("authors"); assertEquals(2, authors.size()); assertEquals("Ted", authors.get(0)); assertEquals("Mark", authors.get(1)); @SuppressWarnings("unchecked") Map<String, Object> date = (Map<String, Object>)m.get("date"); assertEquals(2, date.size()); assertEquals(2013L, date.get("year")); assertEquals(9L, date.get("month")); }
public Map<String, Object> parseObject() throws IOException { Type t = lexer.readNextToken(); if (t != Type.START_OBJECT) { throw new IOException("Unexpected token: " + t); } return parseObjectInternal(); }
JsonParser { public Map<String, Object> parseObject() throws IOException { Type t = lexer.readNextToken(); if (t != Type.START_OBJECT) { throw new IOException("Unexpected token: " + t); } return parseObjectInternal(); } }
JsonParser { public Map<String, Object> parseObject() throws IOException { Type t = lexer.readNextToken(); if (t != Type.START_OBJECT) { throw new IOException("Unexpected token: " + t); } return parseObjectInternal(); } JsonParser(JsonLexer lexer); }
JsonParser { public Map<String, Object> parseObject() throws IOException { Type t = lexer.readNextToken(); if (t != Type.START_OBJECT) { throw new IOException("Unexpected token: " + t); } return parseObjectInternal(); } JsonParser(JsonLexer lexer); Map<String, Object> parseObject(); List<Object> parseArray(); }
JsonParser { public Map<String, Object> parseObject() throws IOException { Type t = lexer.readNextToken(); if (t != Type.START_OBJECT) { throw new IOException("Unexpected token: " + t); } return parseObjectInternal(); } JsonParser(JsonLexer lexer); Map<String, Object> parseObject(); List<Object> parseArray();  }