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]