public static JSONObject parseTargetJson(JSONObject jsonObject) {
JSONObject jsonObject1 = new JSONObject();
JSONArray jsonArray = jsonObject.getJSONObject("data").getJSONArray("result");
for (Object object : jsonArray) {
JSONObject subJson = JSONObject.parseObject(object.toString());
//重新按UTF-8的方式進行編碼
String key = new String(subJson.getJSONObject("metric").getString("title").getBytes(), Charset.forName("UTF-8"));
jsonObject1.put(key, subJson.getJSONArray("value").get(1));
}
return jsonObject1;
}
哪裏出現中文字符亂碼,就用UTF-8重新進行一次編碼。