Convert { public static String mapToJson(Map<String, ?> map) { return DataServices.gson().toJson(map); } private  Convert(); static List<Multimap<String, Object>> anyJsonToJava(String json); static TObject javaToThrift(Object object); static Multimap<String, Object> jsonToJava(String json); @SuppressWarnings("unchecked") static String mapsToJson(Collection<Multimap<String, Object>> list); static String mapToJson(Map<String, ?> map); static String mapToJson(Multimap<String, Object> map); static String operatorToString(Operator operator); @SuppressWarnings("unchecked") static T possibleThriftToJava(Object tobject); static Object stringToJava(String value); static Operator stringToOperator(String symbol); static String stringToResolvableLinkInstruction(String ccl); @Deprecated static String stringToResolvableLinkSpecification(String key,
            String rawValue); static Object thriftToJava(TObject object); static Object toFunctionOrUnescapedValueIfPossible(Object value);  }
@Test public void testConvertMultimapToJson() { Multimap<String, Object> map = LinkedHashMultimap.create(); map.put("a", 1); map.put("a", "1"); map.put("a", 1.00); map.put("b", true); map.put("c", "hello"); map.put("c", "hello world"); String expected = "{\"a\":[1,\"1\",\"1.0D\"],\"b\":true,\"c\":[\"hello\",\"hello world\"]}"; Assert.assertEquals(expected, Convert.mapToJson(map)); }
@Test public void testMultimapWithLinkObjectToJson() { Multimap<String, Object> data = HashMultimap.create(); data.put("foo", Link.to(1)); String json = Convert.mapToJson(data); Assert.assertEquals("{\"foo\":\"@1\"}", json); }
@Test public void testMapWithLinkObjectToJson() { Map<String, Object> data = Maps.newHashMap(); data.put("foo", Link.to(1)); String json = Convert.mapToJson(data); Assert.assertEquals("{\"foo\":\"@1\"}", json); }