return children.toString();
public String getSerializedJSON(final List<MetricName> metricNames) { ArrayNode tokenInfoArrayNode = JsonNodeFactory.instance.arrayNode(); for (MetricName metricName : metricNames) { ObjectNode metricNameInfoNode = JsonNodeFactory.instance.objectNode(); metricNameInfoNode.put(metricName.getName(), JsonNodeFactory.instance.booleanNode(metricName.isCompleteName())); tokenInfoArrayNode.add(metricNameInfoNode); } return tokenInfoArrayNode.toString(); } }
public static String getSerializedJSON(List<SearchResult> searchResults) { ArrayNode resultArray = JsonNodeFactory.instance.arrayNode(); for (SearchResult result : searchResults) { ObjectNode resultNode = JsonNodeFactory.instance.objectNode(); resultNode.put("metric", result.getMetricName()); String unit = result.getUnit(); if (unit != null) { //Preaggreated metrics do not have units. Do not want to return null units in query results. resultNode.put("unit", unit); } resultArray.add(resultNode); } return resultArray.toString(); } }
@Override public String toString() { return wrapped.toString(); }
@Override public String toString() { return wrapped.toString(); }
public static <T> String list2Json(List<T> list){ ArrayNode arrynode = newArrayNode(); for(T t: list){ arrynode.add(bean2Json(t)); } return arrynode.toString(); }
public static String list2Json(List<Map> list,List<String> layout,Object obj){ ArrayNode arrynode = newArrayNode(); for(Map t: list){ arrynode.add(bean2Json(t,layout,obj)); } return arrynode.toString(); }
@Test public void testGetMd5Digest_WithExtraObjects_WithoutUserInfoObject() throws NoSuchAlgorithmException, UnsupportedEncodingException { MessageDigest result = testServlet.getMd5Digest(mockRequest); assertEquals(result, mockDigest); verify(mockDigest, atLeast(3)).update(byteArrayCaptor.capture()); assertArrayEquals(SELECTOR_SCRIPT.getBytes(StandardCharsets.UTF_8), byteArrayCaptor.getAllValues().get(0)); assertArrayEquals(APPLICATION_MODE.getBytes(StandardCharsets.UTF_8), byteArrayCaptor.getAllValues().get(1)); assertArrayEquals(mockPluginDefinitionsArray.toString().getBytes(StandardCharsets.UTF_8), byteArrayCaptor.getAllValues().get(2)); }
@Test @GraphDescription.Graph( value = { "John friend Sara", "John friend Joe", "Sara friend Maria", "Joe friend Steve" }, autoIndexNodes = true ) public void testIterableJSONSerialization() { data.get(); JSONSerializer serializer = new JSONSerializer(); String query = start( lookup( "john", "node_auto_index", "name", "John" ), lookup( "maria", "node_auto_index", "name", "Maria" ) ) .match( shortestPath( "p" ).from( "john" ).out().hops( null,3 ).to( "maria" ) ) .returns( identifier( "p" ) ) .toString(); System.out.println( query ); String json = serializer.toJSON(engine.execute(query)).toString(); System.out.println( json ); }
@Test @GraphDescription.Graph( value = { "John friend Sara", "John friend Joe", "Sara friend Maria", "Joe friend Steve" }, autoIndexNodes = true ) public void testJSONSerialization() { data.get(); JSONSerializer serializer = new JSONSerializer(); String query = start(lookup("john", "node_auto_index", "name", "John")). match(path().from("john").out("friend").link().out("friend").to("fof")). returns(identifier("john").property( "name"), identifier("fof").property( "name"), identifier("john"), count()) .toString(); String json = serializer.toJSON( engine.execute(query) ).toString(); System.out.println( json ); // Now replace names to make it prettier json = serializer.toJSON( new NameResolver(). replace("john.name", "name"). replace("fof.name", "friend"). replace("count(*)", "count"). replace("john", "node").map(engine.execute( query )) ).toString(); System.out.println( json ); }