ITeye博客

JSON

共 3 篇文章

JSONObject put,accumulate,element的区别

public Object put (Object key, Object value) 将value映射到key下。如果此JSONObject对象之前存在一个value在这个key下,当前的value会替换掉之前的value Associates the specified value with the specified key in this map(optional operation). If the map previously contained . a mapping for this key, the old value is replaced by the specifi…

2014-06-16 10:05 · JSON

java 代码 JSON解析

String strTest = "{'one':[ {'two':[ {'three':'去头屑','four':[ {'five':'用立白'},{'six':'和尚洗头'} ] } ]},{'seven':'用飘柔'}]}"; JSONObject obj = JSONObject.fromObject(strTest); //通过key 取到两个对象 JSONArray oneObj = obj.getJSONArray("one"); //根据下标得到对象 JSONObject arrObj = oneObj.getJSONObject(1); System.out.println…

2014-06-06 14:29 · JSON

将JSON转换成MAP的工具类

[code="java"] package digu.pendant.util; import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.net.URL; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import net.sf.json…

2014-06-04 16:16 · JSON · Java · json