JSONObject中方法的区别
来源:互联网 发布:桌面视频录制软件 编辑:程序博客网 时间:2024/05/01 10:45
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.
转自 http://blog.csdn.net/cocodehouse/article/details/5996088 ,保存这这里方便下次查看
- JSONObject中方法的区别
- Android中JSONObject与JsonObject的区别
- JSONObject 方法区别
- spring中注解JSONObject,string类型转换为JSONObject以及JSONObject的遍历方法
- JSONObject/JSONArray的区别
- 操纵JsonObject的方法
- 操纵JsonObject的方法
- 操纵JsonObject的方法
- 操纵JsonObject的方法
- JSONObject中optString和getString等的区别
- 关于json-lib中JSONObject的formString静态方法
- JsonObject和JsonArray的区别
- JSONArray和JSONObject的区别
- JSONObject与JSONArray的区别
- JSONObject和JSONArray的区别
- JSONObject和JSONArray的区别
- JSONArray和JSONObject的区别
- JSONObject和JSONArray的区别
- HDOJ P1022 汉字统计
- Linux时间函数C++之gettimeofday()函数之使用方法
- 隐藏在内部的Bug KsMarketDataRepatchInterfaceReceiver
- JAVA 线程间通信 - 生产者与消费者
- 查看、分析memcached使用状态
- JSONObject中方法的区别
- android 之用ActivityGroup 实现Tab分页
- Qt Creator 不能解析库函数
- USACO Section 1.2.5 Palindromic Squares
- linux scp远程拷贝文件及文件夹
- 从标签中取值
- 关键字static,const,volatile,auto,register
- php一个很纠结的问题---括号
- JPEG图像的解压缩操作