标签:format sys 统一 开始 key 代码 讲解 ice int
1 JSONObject jsonObject = JSONObject.parseObject(jsonstring); 2 JSONArray jsonArray = jsonObject.getJSONArray("skuList"); 3 for (Object object : jsonArray) { 4 JSONObject midObject = (JSONObject) object; 5 BigDecimal price = midObject.getBigDecimal("price"); 6 midObject.put("price", new BigDecimal(String.format("%.2f", price.doubleValue()))); 7 }
1 JSONObject json = JSON.parseObject("{val: 123}"); 2 System.out.println("======before====="); 3 System.out.println("size: " + json.size()); 4 System.out.println("val: " + json.get("val")); 5 //直接put相同的key 6 json.put("val", 234); 7 System.out.println("======after======"); 8 System.out.println("size: " + json.size()); 9 System.out.println("val: " + json.get("val")); 10 结果 11 12 ======before===== 13 size: 1 14 val: 123 15 ======after====== 16 size: 1 17 val: 234
标签:format sys 统一 开始 key 代码 讲解 ice int
原文地址:https://www.cnblogs.com/coder-wf/p/12130804.html