接收 JsonArray 作为来自 post 请求的响应



我想知道有没有办法接收JsonArray作为来自 post 请求的响应。问题是我的回答是JSONObject类型。我知道如何从字符串类型响应中获取响应,我想知道从JSONObject类型响应中获取响应的方法。

这是我想得到的回应JSONArray

{
"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
}

您始终可以解析为 json。但首先使该字符串的格式正确:

[{ "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,"isDelete": 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": "您的病房####
今天缺席,没有事先信息。请发送请假信 - ####", "message1": null, "isHalfDay": null },{//这将是第二行"attendanceID": 455435,"attendeeUserID": 46114, "batchId": 1466, "DepartmentId": (...)}]

编辑:如何减去:

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;

(在JavaScript中)

要在安卓中执行此操作:

已经在这里回答了

最新更新