@Test public void object() throws Exception { ObjectTree tree = (ObjectTree) ((JsonTree) parser.parse("{}")).arrayOrObject(); assertThat(tree.openCurlyBraceToken().value()).isEqualTo("{"); assertThat(tree.closeCurlyBraceToken().value()).isEqualTo("}"); assertThat(tree.pairs()).isNull(); tree = (ObjectTree) ((JsonTree) parser.parse("{ \"string\" : true }")).arrayOrObject(); assertThat(tree.pairs()).isNotNull(); assertThat(tree.pairs().next()).isNull(); PairTree pair = tree.pairs().element(); assertThat(pair.name().token().value()).isEqualTo("\"string\""); assertThat(((BuiltInValueTree) pair.value()).token().value()).isEqualTo("true"); assertThat(pair.colonToken().value()).isEqualTo(":"); parser.parse("{ \"string\" : true, \"string\" : false }"); }
public ObjectTree OBJECT() { return b.<ObjectTree>nonterminal(JsonLexer.OBJECT).is( f.object( b.token(JsonLexer.LCURLYBRACE), b.optional(PAIR_LIST()), b.token(JsonLexer.RCURLYBRACE))); }
JsonGrammar { public ObjectTree OBJECT() { return b.<ObjectTree>nonterminal(JsonLexer.OBJECT).is( f.object( b.token(JsonLexer.LCURLYBRACE), b.optional(PAIR_LIST()), b.token(JsonLexer.RCURLYBRACE))); } }
JsonGrammar { public ObjectTree OBJECT() { return b.<ObjectTree>nonterminal(JsonLexer.OBJECT).is( f.object( b.token(JsonLexer.LCURLYBRACE), b.optional(PAIR_LIST()), b.token(JsonLexer.RCURLYBRACE))); } JsonGrammar(GrammarBuilder<InternalSyntaxToken> b, TreeFactory f); }
JsonGrammar { public ObjectTree OBJECT() { return b.<ObjectTree>nonterminal(JsonLexer.OBJECT).is( f.object( b.token(JsonLexer.LCURLYBRACE), b.optional(PAIR_LIST()), b.token(JsonLexer.RCURLYBRACE))); } JsonGrammar(GrammarBuilder<InternalSyntaxToken> b, TreeFactory f); JsonTree JSON(); ObjectTree OBJECT(); SyntaxList<PairTree> PAIR_LIST(); PairTree PAIR(); ArrayTree ARRAY(); SyntaxList<ValueTree> VALUE_LIST(); ValueTree VALUE(); LiteralTree STRING(); LiteralTree NUMBER(); BuiltInValueTree BUILT_IN_VALUE(); }
JsonGrammar { public ObjectTree OBJECT() { return b.<ObjectTree>nonterminal(JsonLexer.OBJECT).is( f.object( b.token(JsonLexer.LCURLYBRACE), b.optional(PAIR_LIST()), b.token(JsonLexer.RCURLYBRACE))); } JsonGrammar(GrammarBuilder<InternalSyntaxToken> b, TreeFactory f); JsonTree JSON(); ObjectTree OBJECT(); SyntaxList<PairTree> PAIR_LIST(); PairTree PAIR(); ArrayTree ARRAY(); SyntaxList<ValueTree> VALUE_LIST(); ValueTree VALUE(); LiteralTree STRING(); LiteralTree NUMBER(); BuiltInValueTree BUILT_IN_VALUE();  }