Java Code Examples for elemental.json.JsonObject#toJson()
The following examples show how to use
elemental.json.JsonObject#toJson() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UidlRequestHandler.java From flow with Apache License 2.0 | 5 votes |
void writeUidl(UI ui, Writer writer, boolean resync) throws IOException { JsonObject uidl = createUidl(ui, resync); if (ui instanceof JavaScriptBootstrapUI) { removeOffendingMprHashFragment(uidl); } // some dirt to prevent cross site scripting String responseString = "for(;;);[" + uidl.toJson() + "]"; writer.write(responseString); }
Example 2
Source File: UsageStatisticsExporter.java From flow with Apache License 2.0 | 5 votes |
private static String createUsageStatisticsJson(UsageStatistics.UsageEntry entry) { JsonObject json = Json.createObject(); json.put("is", entry.getName()); json.put("version", entry.getVersion()); return json.toJson(); }
Example 3
Source File: UidlRequestHandlerTest.java From flow with Apache License 2.0 | 4 votes |
@Test public void should_not_modify_non_MPR_Uidl() throws Exception { JavaScriptBootstrapUI ui = mock(JavaScriptBootstrapUI.class); UidlRequestHandler handler = spy(new UidlRequestHandler()); StringWriter writer = new StringWriter(); JsonObject uidl = generateUidl(true, true); uidl.getArray("execute").getArray(2).remove(1); doReturn(uidl).when(handler).createUidl(ui, false); handler.writeUidl(ui, writer, false); String expected = uidl.toJson(); String out = writer.toString(); uidl = JsonUtil.parse(out.substring(9, out.length() - 1)); String actual = uidl.toJson(); assertEquals(expected, actual); }