### Question:
JsonConversionUtil { static JSONObject parametersToJsonObject(Map<String, String> params) throws JSONException { JSONObject root = new JSONObject(); for (Map.Entry<String, String> entry : params.entrySet()) { String[] path = StringUtils.splitPreserveAllTokens(entry.getKey(), '.'); JSONObject holder = buildHolder(root, path, 0); if (path.length > 1) { holder.put(path[path.length - 1], convertToJsonValue(entry.getValue())); } else { holder.put(path[0], convertToJsonValue(entry.getValue())); } } return root; } private  JsonConversionUtil(); @SuppressWarnings("unchecked") static JSONObject fromRequest(HttpServletRequest request); static Map<String, String> fromJson(JSONObject obj); static boolean isAllLiterals(JSONArray jsonArr);  }### Answer:
@Test public void testParameterMapToJsonParsing() throws Exception { assertJsonEquals(JsonConversionUtil.parametersToJsonObject(ImmutableMap.of("a.b.c", "1")), new JSONObject("{a:{b:{c:1}}}")); assertJsonEquals( JsonConversionUtil.parametersToJsonObject(ImmutableMap.of("a.b.c", "\"1\"")), new JSONObject("{a:{b:{c:\"1\"}}}")); assertJsonEquals(JsonConversionUtil.parametersToJsonObject(ImmutableMap.of("a.b.c", "true")), new JSONObject("{a:{b:{c:true}}}")); assertJsonEquals( JsonConversionUtil.parametersToJsonObject(ImmutableMap.of("a.b.c", "false")), new JSONObject("{a:{b:{c:false}}}")); assertJsonEquals(JsonConversionUtil.parametersToJsonObject(ImmutableMap.of("a.b.c", "null")), new JSONObject("{a:{b:{c:null}}}")); assertJsonEquals(JsonConversionUtil.parametersToJsonObject( ImmutableMap.of("a.b(0).c", "hello", "a.b(1).c", "hello")), new JSONObject("{a:{b:[{c:\"hello\"},{c:\"hello\"}]}}")); assertJsonEquals(JsonConversionUtil.parametersToJsonObject( ImmutableMap.of("a.b.c", "hello, true, false, null, 1,2, \"null\", \"()\"")), new JSONObject("{a:{b:{c:[\"hello\",true,false,null,1,2,\"null\",\"()\"]}}}")); assertJsonEquals(JsonConversionUtil.parametersToJsonObject( ImmutableMap.of("a.b.c", "\"hello, true, false, null, 1,2\"")), new JSONObject("{a:{b:{c:\"hello, true, false, null, 1,2\"}}}")); }