JSONObject转string在转JSONArray
String data = net.sf.json.JSONObject.fromObject(restTemplate.getForEntity(url, String.class).getBody()).getString("data");
JSONArray list = JSONArray.parseArray(data);
for (int i = 0; i < list.size(); i++) {
String cooperPrice = list.getJSONObject(i).getString("cooperPrice");
System.out.println("cooperPrice = " + cooperPrice);
costPrice = Double.valueOf(JSONObject.parseObject(list.get(i).toString()).getString("cooperPrice"));
shopPrice = Double.valueOf(JSONObject.parseObject(list.get(i).toString()).getString("marketPrice"));
}
这种转化是不行的 会报错
JSONObject.parseObject(data).getJSONArray("list");
这样也不行 date:"[ ]"的形式 只能转jisnArray 然后遍历获取
JSONObject.parseObject(data).getString("cooperPrice")