### Question:
TreeUtil { public static String toJson(Object obj) throws EncodeException { try { return json.writeValueAsString(obj); } catch (Exception e) { throw new EncodeException(String.format(ENCODE_ERR_MSG, e.getMessage())); } } private  TreeUtil(); static String toJson(Object obj); static JsonNode toJsonNode(Object obj); static String toYaml(Object obj); static T load(final URL url, Class<T> clazz); static T load(final URL url, final List<AuthOption> authOptions, Class<T> clazz); static JsonNode load(final URL url); static JsonNode load(final URL url, final List<AuthOption> authOptions); static final String ENCODE_ERR_MSG; static final ObjectMapper json; static final ObjectMapper yaml; }### Answer:
@Test(expected = EncodeException.class) public void toJson() throws EncodeException, JSONException { Map<String, Object> map = new HashMap<>(); map.put("akey", "aValue"); String str = TreeUtil.toJson(map); JSONAssert.assertEquals("{\"akey\": \"aValue\"}", str, true); map.put(null, "aValue"); TreeUtil.toJson(map); }