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的区别的更多相关文章

  1. JSONObject put accumulate element 方法区别-------java中

    1.public Object put (Object key, Object value) 将value映射到key下.如果此JSONObject对象之前存在一个value在这个key下,当前的va ...

  2. JSONObject put,accumulate,element的区别(转载)

    原文链接:http://ljhzzyx.blog.163.com/blog/static/3838031220126810430157/   public Object put (Object key ...

  3. 转JSONObject put,accumulate,element的区别

        public Object put (Object key, Object value) 将value映射到key下.如果此JSONObject对象之前存在一个value在这个key下,当前的 ...

  4. ExtJS学习之路第二步:Ext.Component 和 Ext.dom.Element 的区别

    让我们来初步的探讨下Ext.Component和Ext.Element的区别. jQuery偏重于DOM元素的操作 1.每一个HTML页面都有一个层次分明的DOM树模型,浏览器中的所有内容都有相应的D ...

  5. JSON.parseObject(String str)与JSONObject.parseObject(String str)的区别

    一.首先来说说fastjson fastjson 是一个性能很好的 Java 语言实现的 JSON 解析器和生成器,来自阿里巴巴的工程师开发.其主要特点是: ① 快速:fastjson采用独创的算法, ...

  6. JSONObject与JSONArray的使用区别

    1.JSON 1. 创建一个JSONObject对象: package com.yunos.tv.video.resource.controller.web; import java.util.Arr ...

  7. DOM中的node与element的区别

    先看document的两个常见method. document.createTextNode Constructor: Text document.createElement Constructor: ...

  8. xml中Node和Element的区别

    本文转载自:http://blog.csdn.net/wcydiyi/article/details/4432636点击打开链接 1.元素(Element)和结点(Node)的区别:         ...

  9. java Queue中 remove/poll, add/offer, element/peek区别

    offer,add区别: 一些队列有大小限制,因此如果想在一个满的队列中加入一个新项,多出的项就会被拒绝. 这时新的 offer 方法就可以起作用了.它不是对调用 add() 方法抛出一个 unche ...

随机推荐

  1. python练习

    创建一个简单的姓名和编号系统,让用户输入一组人的姓名和编号,实现提供按照编号或姓名排序输出的功能. nums = [] names = [] Afternums = [] Afternames = [ ...

  2. openx中如何使用site-variable(参数)限制(关键词)广告显示

    openx是个很强大的广告管理系统,可以根据不同的情况显示不同的广告.其中可以根据get参数值的不同来显示,即delivery limitation中的site-variable选项,name表示变量 ...

  3. Android中AsyncTask使用

    一.AsyncTask的作用: 代替Thread+Handler的组合,使创建异步任务变得简单. AsyncTask执行后台操作,并在用户界面上发布结果,而不必处理线程. 二.AsyncTask的定义 ...

  4. C++11 auto and decltype

    1.auto关键字 C++新标准引入auto关键词,此auto与之前C语言的auto意义已经不一样了. 这里的auto是修饰未知变量的类型,编译器会通过此变量的初始化自动推导变量的类型. 例如:aut ...

  5. JavaScript简单的tabel切换2

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  6. myString操作符重载

    写在前面的话: 重载是C++的重要内容,在自定义一个类的时候,需要对类中的方法进行重载,才能方便的实现相应的功能,比如一些运算符,构造,析构函数,一些功能函数等等,而C++语言自带的这些东西只使用于基 ...

  7. Volley

    Volley 是 Google 推出的轻量级 Android 异步网络请求框架和图片加载框架.在 Google I/O 2013 大会上发布.其适用场景是数据量小,通信频繁的网络操作. 主要特点: ( ...

  8. java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer)可能出现的原因

    可能是因为你的服务器http连接过多,导致端口被占用,无法释放

  9. context上下文 php版解释

    context翻译为上下文其实不是很好,只是翻译理解大概的作用,对于开发来说,context是对定义的使用的变量,常量或者说是配置, 部分的函数功能除了缺省值之外,往往需要手动设置一些定义量来配合当前 ...

  10. php-fpm重启关闭等操作

    php-fpm 启动:/usr/sbin/php-fpmphp-fpm 关闭:kill -INT `cat /var/run/php-fpm.pid`php-fpm 重启:kill -USR2 `ca ...