The difference between Jsonobject put,accumulate,element (reprint)

Source: Internet
Author: User

Original link: Http://ljhzzyx.blog.163.com/blog/static/3838031220126810430157/ public object put (object key, Object Value) to map value to key. If there is a value before this Jsonobject object under this key, the current value will replace the previous valueassociates the specified value with the specified key in this map ( Optional operation). If the map previously contained. A mapping for this key, and the old value was 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) accumulates value under this key. This method is similar to the element () method, especially if a value is already present under this key and a jsonarray will be stored in this key to save all accumulated value. If a jsonarray already exists, then the current value is added to the Jsonarray. In contrast, the Replace method replaces the previous valueaccumulate values under a key. It is similar to the element method except so if there is already an object Stored under the key then a jsonarray I s stored under the key to the accumulated values. If there is already a jsonarray and then the new value is AppendeD to it. In contrast, the Replace method replaces the previous value. public jsonobject element (String key, Object value) will key/ Value pairs are placed inside the Jsonobject object. If the current value is null (NULL), the key is removed if the key exists. This method calls the accumulate () method if the key has a value before it. Put a Key/value pair in the jsonobject. If the value is null and then the key would be removed from the jsonobject if it is present. If There is a previous value assigned to the key, it'll call accumulate.

Jsonobject put,accumulate,element Difference (reprint)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.