### Question:
JSONUtils { public static String buildJSON(Map<String, Object> params) { final StringWriter stringWriter = new StringWriter(); final JsonGenerator generator = GENERATOR_FACTORY.createGenerator(stringWriter); generator.writeStartObject(); for (Map.Entry<String, Object> param : params.entrySet()) { String key = param.getKey(); Object value = param.getValue(); if (key != null && value != null) { if (value instanceof Boolean) { generator.write(key, (Boolean) value); } else if (value instanceof Double) { generator.write(key, (Double) value); } else if (value instanceof Integer) { generator.write(key, (Integer) value); } else if (value instanceof BigDecimal) { generator.write(key, (BigDecimal) value); } else if (value instanceof BigInteger) { generator.write(key, (BigInteger) value); } else if (value instanceof Long) { generator.write(key, (Long) value); } else if (value instanceof String) { String string = (String) value; if (!string.isEmpty()) { generator.write(key, string); } } else if (value.getClass().isArray()) { generator.writeStartArray(key); for (int i = 0; i < Array.getLength(value); i++) { witeItem(generator, Array.get(value, i)); } generator.writeEnd(); } else if (value instanceof Collection) { generator.writeStartArray(key); Collection<?> collection = (Collection<?>) value; for (Object item : collection) { witeItem(generator, item); } generator.writeEnd(); } } } generator.writeEnd().close(); return stringWriter.toString(); }  static String buildJSON(Map<String, Object> params); static Map<String, Object> parseJSON(String jsonBody);  }### Answer:
@Test public void testBuildJSON() throws Exception { Map<String, Object> params = new HashMap<String, Object>(); params.put(OAuthError.OAUTH_ERROR, OAuthError.TokenResponse.INVALID_REQUEST); String json = JSONUtils.buildJSON(params); assertEquals("{\"error\":\"invalid_request\"}", json); }