JsonGenerator { public static JsonValue createJsonObjectFromMap(Map<String, ?> map) throws JsonException { if (map == null) { return new NullValue(); } return createJsonValue(map, MAP); }  static JsonValue createJsonArray(Collection<?> collection); static JsonValue createJsonArray(Object array); static JsonValue createJsonObjectFromMap(Map<String, ?> map); static JsonValue createJsonObject(Object object);  }
@Test public void convertsMapToJson() throws Exception { Map<String, Book> books = ImmutableMap.of("0", junitBook, "1", csharpBook, "2", javaScriptBook); JsonValue jsonValue = JsonGenerator.createJsonObjectFromMap(books); assertTrue(jsonValue.isObject()); assertionHelper.assertThatJsonHasAllItemsFromMap(books, jsonValue); }
@Test public void convertsNullMapToJson() throws Exception { JsonValue jsonValue = JsonGenerator.createJsonObjectFromMap(null); assertTrue(jsonValue.isNull()); }