public <E> JSON merge(Map<String, E> map) { for (Map.Entry<String, E> entry : map.entrySet()) { set(entry.getKey(), entry.getValue()); } return this; }
public JSON toJSON() { JSON json = new JSON(); json.set("path", path.getCanonical()); return json; }
final public void pair(JSON m) throws ParseException { Token t = null; Object o; String fieldName = null; fieldName = fieldName(); jj_consume_token(O_COLON); o = value(); m.set(fieldName, o); }
@Override public JSON toJSON() { JSON json = new JSON(); json.map("values", getChildren(TemplateMetaModel.class)); json.set("qn", qn); return json; }
public JSON toJSON() { JSON json = new JSON(); json.set("handle", handle); json.map("methods", getHandlers()); return json; }
final public void pair(JSON m) throws ParseException { Token t = null; Object o; String fieldName = null; fieldName = fieldName(); jj_consume_token(O_COLON); o = value(); m.set(fieldName, o); }
public JSON toJSON() { JSON json = new JSON(); json.set("handle", handle); json.map("methods", getHandlers()); return json; }
@Test public void testWriteIndented() throws Exception { assertEquals("{\n" + " \"a\":\"a_value\",\n" + " \"b\":2,\n" + " \"c\":[1,2,3],\n" + " \"d\":{\n" + " \"e\":true\n" + " }\n" + "}", JSON.toString(new JSON().set("a", "a_value").set("b", 2).list("c", 1, 2, 3).set("d", new JSON().set("e", true)), new StringBuilder(), 2).toString()); } }
@Override public JSON toJSON() { JSON json = new JSON(); for (ModuleMetaModelPlugin plugin : context.getPlugins()) { JSON pluginJSON = plugin.toJSON(this); json.set(plugin.getName(), pluginJSON); } return json; }
@Override public JSON toJSON() { JSON json = new JSON(); for (ModuleMetaModelPlugin plugin : context.getPlugins()) { JSON pluginJSON = plugin.toJSON(this); json.set(plugin.getName(), pluginJSON); } return json; }
@Test public void testUnwrapArray() throws Exception { JSON json = new JSON().set("foo", (Object)new String[]{"bar_1", "bar_2"}); assertEquals(Arrays.asList("bar_1", "bar_2"), json.getList("foo")); }
@Test public void testNull() throws Exception { JSON json = new JSON().set("foo", null); String s = json.toString(); assertEquals("{\"foo\":null}", s); JSON unmarshalled = (JSON)JSON.parse(s); assertEquals(json, unmarshalled); }