JSONObject 几个方法的区别 ? 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 specified value. (A map?m?is said to contain a mapping for a key?k?if and only if m.containsKey(k) would return?true?.))
public JSONObject?accumulate?(String key, Object value) 累积value到这个key下。这个方法同element()方法类似,特殊的是,如果当前已经存在一个value在这个key下那么一个JSONArray将会存储在这个key下来保存所有累积的value。如果已经存在一个JSONArray,那么当前的value就会添加到这个JSONArray中
。相比之下replace方法会替代先前的value
Accumulate values under a key. It is similar to the element method except that if there is already an object stored?
under the key then a JSONArray is stored under the key to hold all of the accumulated values. If there is already a?
JSONArray, then the new value is appended to it. In contrast, the replace method replaces the previous value.
public JSONObject?element?(String key, Object value) 将键/值对放到这个JSONObject对象里面。如果当前value为空(null),那么如果这个key存在的话,这个key就会移除掉。如果这
个key之前有value值,那么此方法会调用accumulate()方法。
Put a key/value pair in the JSONObject. If the value is null, then the key will be removed from the JSONObject if it is?
present. If there is a previous value assigned to the key, it will call accumulate.
详细解决方案
JSONObject put accumulate element 步骤区别
热度:688 发布时间:2012-06-27 14:20:09.0
相关解决方案
- soap调用webservice,报错:Root element of a SOAP message must be: 'http://schemas.xmls,该怎么处理
- clearcase 中怎么查看一个element 是symbolic link 还是 实际的file element
- 如何区分Struts Action Element?(已解决)
- IE Developer Toolbar不能用“Select Element By Click"功能
- 请问:The content of element type " " must match "EMPTY"
- net.sf.json.JSONObject cannot be resolved解决办法
- IE Developer Toolbar不能用“Select Element By Click"效能
- 分享一个在线的HTML5元素在线试验 : HTML5 Element Quiz
- ajax JSONObject.fromObject 执行的时候没有任何反映,该怎么处理
- Ajax异常:Sys.ArgumentNullException: Value cannot be null. Parameter name: element
- 架构证验警告: 来自命名空间“xxx”、名为“XXX”的架构项“element”无效。在此架构中不能引用命名空间“xxx”
- WCF异常SerializationException:“Element”命名空间 中的xxx并非所需元素
- HTML Parsing Error: Unable to modify the parent container element before the chi,该如何处理
- 解决 element.style覆盖样式有关问题
- Unrecognized xbean element 地图ping: beans in namespace http://xfire.codehaus.org/config/1.0
- element.style覆盖样式解决办法
- web service 请求https地址失误There must be a method name element
- The prefix "aop" for element "aop:config" is not bound
- prototype里Form.Element.focus(element) 方法是否实现异常
- EXT核心API详解(3)-Ext.Element
- [转载]JSONObject.fromObject(地图)(JSON与JAVA数据的转换)
- 【ExtJS 4.1】Element.load()加载不成功,该如何处理
- JSONObject 解析json的步骤
- this.optional(element) 代表什么解决方案
- jsonObject 转化应用
- jsonObject 转化 bean list 地图 array
- 关于json的操作 jsonArray-jsonObject
- extJs 2.0学习札记(Element.js篇)
- new JSONObject()不执行 不报错 解决办法
- Extjs4-json处理日期的有关问题,JSONObject.toBean转换日期时显示当前日期