i want to create jsonarray but i am new here so tried my best but unable to do that can anybody help me in that. Thanks i already know i to get data from this array but now i want to insert my text in this format of json array to post to database
{
"ServiceVisitID": 1,
"ServiceItemID": 2,
"ItemDescription": "sample string 3",
"SerialNumber": "sample string 4",
"ItemLocation": "sample string 5",
"ServiceTasks": [
{
"TaskID": 1,
"Task": "sample string 2",
"Description": "sample string 3",
"done": true,
"Notes": "sample string 5",
"ReasonID": 6,
"ResultTypeID": 7
},
{
"TaskID": 1,
"Task": "sample string 2",
"Description": "sample string 3",
"done": true,
"Notes": "sample string 5",
"ReasonID": 6,
"ResultTypeID": 7
}
],
"ItemAttended": true,
"NotAttendedReasonCode": "sample string 7",
"ActionRequiredID": 8,
"ItemsRequired": [
{
"ItemID": 1,
"StockCode": "sample string 2",
"Description": "sample string 3",
"Quantity": 4
},
{
"ItemID": 1,
"StockCode": "sample string 2",
"Description": "sample string 3",
"Quantity": 4
}
],
"FurtherVisitRequired": true,
"Notes": "sample string 10",
"ServiceComplete": true,
"Code":
"Message":
}
my present code that i only able to make just 5 first obj but after that there is further array of ServiceTasks so i am confused in this
JSONArray jsonArray=new JSONArray();
JSONObject ob=new JSONObject();
ob.put("ServiceVisitID","1");
ob.put("ServiceItemID","1");
ob.put("ItemDescription","check");
ob.put("SerialNumber","check");
JSONObject itemlocationob= ob.put("SerialNumber");
ob.put("ItemLocation","check");
JSONArray ServiceTasks=new JSONArray();
JSONObject ServiceTasksob=new JSONObject();
ServiceTasksob.put("TaskID","1");
ServiceTasksob.put("TaskID","1");
ServiceTasksob.put("TaskID","1");
ServiceTasks.put(jsonObject1);
ob.put("",ServiceTasks);