JSON processing simple solution [Jsonobject, Jsonarray]

Source: Internet
Author: User

JSON processing currently has a mature use of jar can support related processing, json-lib

Common methods are put, Putall, add
The Put method has the following parameters: Key, Value/jsonobject
Supports JSON object assignment and wrapper sub-JSON strings (that is, the value in the JSON string assignment can be a JSON object)
Putall method parameters are: Jsonobject
Supports assignment of JSON objects (assigning one JSON object directly to another)
The Add method passes a parameter to an array location and array object
Add (int index, Object value)

Soapui Use Example:

JSON Object Assembly

Import // declaring a reference package New // declaring Objects // assigning to Objects (Key,value)

JSON array Assembly

Import // declaring a reference package New // declaring Objects // assigning to Objects (Key,value)

Blending examples

1 ImportNet.sf.json.JSONObject;2 ImportNet.sf.json.JSONArray;3 4Jsonobject obj1 =NewJsonobject ();5Jsonarray Obj2 =NewJsonarray ();6Jsonobject obj3 =NewJsonobject ();7 8def orderno= ' 123345345 '9def MemberID = ' 123345345 'Tendef resprincipal = ' 16200.00 ' Onedef restotalamt = ' 16200.00 ' A  -def origtotalamt = ' 16200.00 ' -def origprincipal = ' 16200.00 ' thedef origamt = ' 16200.00 ' -  - //Traveitem Content -Obj1.put ("Repaidfee", "0.00"); +  -Obj2.add (0, obj1); +  AObj3.put ("OrderNo", OrderNo); atObj3.put ("Schedules", obj2); - Log.info obj3 - returnObj3

Example results

1 {2     "OrderNo": "123123123",3     "Schedules": [{4         " Repaidfee ":" 0.00 "5    }]6 }

Reference documents
API links for Jsonobject and Jsonarray:
Http://json-lib.sourceforge.net/apidocs/jdk15/net/sf/json/JSONObject.html
Http://json-lib.sourceforge.net/apidocs/net/sf/json/JSONArray.html

http://blog.csdn.net/shanliangliuxing/article/details/25163005

JSON processing simple solution [Jsonobject, Jsonarray]

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.