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的区别

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

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

    原文链接:http://ljhzzyx.blog.163.com/blog/static/3838031220126810430157/   public Object put (Object 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. java.util.regex.PatternSyntaxException: Dangling meta character '*' near index 0 *&* 解决方法

    java.util.regex.PatternSyntaxException: Dangling meta character '*' near index 0*&*^    at java. ...

  2. HW4.8

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  3. HDU3695 - Computer Virus on Planet Pandora(AC自动机)

    题目大意 给定一个文本串T,然后给定n个模式串,问有多少个模式串在文本串中出现,正反都可以 题解 建立好自动机后.把文本串T正反各匹配一次,刚开始一直TLE...后面找到原因是重复的子串很多以及有模式 ...

  4. 用g++ 编译 ffmpeg 编译出现 error: 'UINT64_C' was not declared in this scope 或 missing -D__STDC_CONSTANT_MACROS

    在 libavutil/common.h 下 添加如下,即可解决 #ifdef __cplusplus#define __STDC_CONSTANT_MACROS#ifdef _STDINT_H#un ...

  5. windows下利用dll生成lib

    原来工程编译的一些dll库,这次项目需要静态库,偷懒想直接转化.看到网上一些教程,使用VC工具和建立lib项目来实现.有点麻烦.还有一种方法,仅仅利用工具和几条命令转化.来试试看.文章参考harrie ...

  6. python 实战

    用Python写一个真正的Web App! 目标 我们设定的实战目标是一个Blog网站,包含日志.用户和评论3大部分. 比如webpy.org上就提供了一个Blog的例子,目测也就100行代码. 我们 ...

  7. "用wow64exts调试64位任务管理器抓取的32位程序的dump"

    博客搬到了fresky.github.io - Dawei XU,请各位看官挪步.最新的一篇是:"用wow64exts调试64位任务管理器抓取的32位程序的dump".

  8. chrome扩展——Postman

    今天须要測试一个http的接口,曾经都是使用java的httpClient工具jar,自己编写代码去调试,但这样的方式比較死板,每次都要执行一段代码...于是就像有没有类似的在线工具能够使用? 调查了 ...

  9. Thinkpad SL400安装黑苹果10.8.4全纪录

    提要 还在为学习苹果开发的装备发愁么 ,也许这篇文章会给你带来一些启发. 关于黑苹果:从苹果采用intel的处理器之后,mac os被黑客破解之后可以安装在PC上,从而出现了一大批未购买苹果机而使用苹 ...

  10. 微软正式提供Visual Studio 2013正式版下载(附直接链接汇总)

    转自 http://www.iruanmi.com/visual-studio-2013/ 微软已经向MSDN订阅用户提供了Visual Studio 2013正式版镜像下载,只是非MSDN用户能够在 ...