-1

I want to know is there any way to receive JsonArray as a response from a post request. The problem is my response is a JSONObject type. I know how to get response from String type response, I want to know the method to get response from a JSONObject type response.

this is the JSONArray I want to get as response.

{
    "attendanceID": 237674,
    "attendeeUserID": 46114,
    "batchId": 1466,
    "departmentId": null,
    "organizationId": 4,
    "leaveTypeId": null,
    "attandanceType": 1,
    "absentDate": "2017-06-12T00:00:00",
    "comment": null,
    "subjectId": null,
    "isAbsent": true,
    "markedBy": 2780,
    "isDeleted": false,
    "dateTimeStampIns": "2017-06-12T13:11:50.9457068+05:30",
    "dateTimeStamp": "2017-06-12T13:11:50.9457068+05:30",
    "attandeeName": null,
    "businessDays": 0,
    "templateId": 1,
    "message": "Your ward #### is absent today WITHOUT PRIOR INFORMATION. Kindly send the Leave Letter - ####",
    "message1": null,
    "isHalfDay": null
}
Mihai Iorga
  • 39,330
  • 16
  • 106
  • 107
D.A
  • 1
  • 2

1 Answers1

-1

You can always parse to json. But first make that string properly formatted:

[{ "attendanceID": 237674, "attendeeUserID": 46114, "batchId": 1466, "departmentId": null, "organizationId": 4, "leaveTypeId": null, "attandanceType": 1, "absentDate": "2017-06-12T00:00:00", "comment":
null, "subjectId": null, "isAbsent": true, "markedBy": 2780,
"isDeleted": false, "dateTimeStampIns":
"2017-06-12T13:11:50.9457068+05:30", "dateTimeStamp":
"2017-06-12T13:11:50.9457068+05:30", "attandeeName": null,
"businessDays": 0, "templateId": 1, "message": "Your ward #### is
absent today WITHOUT PRIOR INFORMATION. Kindly send the Leave Letter - ####", "message1": null, "isHalfDay": null },{//this will be second row"attendanceID": 455435,"attendeeUserID": 46114, "batchId": 1466, "departmentId": (...)}]

EDIT: How to substract:

var text = '[{"description":"about_text","value":"test1","patience":"over9000"}]';

obj = JSON.parse(text);
var yourvar_description = obj[0].description;
var yourvar_value = obj[0].value ;
var yourvar_patience = obj[0].patience;

(in javascript)

To do it in android:

Already answered here

Foo Bar
  • 165
  • 2
  • 14