1
@Test public void test12() { String a = "[{\"screenType\":null,\"scenarioType\":null,\"viewType\":null,\"id\":\"31515\",\"ids\":null,\"batches\":null,\"tableFlag\":null,\"commonDescription\":null,\"commonDescriptionCn\":null,\"commonDisplay\":null,\"commonNo\":\"SCRM2022111024696\",\"commonHeadline\":\"欧供分销延误风险自动感知2022-11-10\",\"commonHeadlineCn\":null,\"commonDisplayCn\":null,\"commonBcmflag\":\"0\",\"commonCardtype\":null,\"commonOccuancedate\":\"2022-11-10 03:32:03\",\"riskPredictedRealtimeLoss\":null,\"riskIdentifiedLoss\":null,\"businessDomain\":null,\"commonRdcName\":null,\"commonBgKey\":null,\"commonIncreasewayDesc\":\"system\",\"commonIocRiskDesc\":\"否\"}]"; JSONArray jsonArray = JSONArray.parseArray(a); JSONObject jsonObject = (JSONObject) jsonArray.get(0); String commonCategorylv2 = jsonObject.getString("commonCategorylv2"); System.out.println(commonCategorylv2); }
2
String result = HttpUtils.postRequest(url, JSONObject.toJSONString(apiParam), headerMap); JSONObject resultObject = JSONObject.parseObject(result); return buildBasicChart(resultObject, titile, xName, yName); public static BasicChart buildBasicChart(JSONObject result, String title, String xName, String yName) { BasicChart basicChart = new BasicChart(); basicChart.setTitle(title); JSONArray jsonArray = result.getJSONArray("list"); for (int i = 0; i < jsonArray.size(); i++) { JSONObject item = jsonArray.getJSONObject(i); if (StringUtils.isNotBlank(item.getString(xName)) && StringUtils.isNotBlank(item.getString(yName))) { basicChart.getXAxis().add(item.getString(xName)); basicChart.getYAxis().add(Double.valueOf(item.getString(yName))); } } return basicChart; }
标签:jsonArray,basicChart,String,对象,JSONObject,转化,item,Json,null From: https://www.cnblogs.com/mingruifeng/p/16949883.html