我想知道有没有办法接收JsonArray
作为回复请求的回复。问题是我的回复是JSONObject
类型。我知道如何从String类型响应中获得响应,我想知道从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
}
答案 0 :(得分:-1)
你总是可以解析为json。但首先要正确格式化该字符串:
[ {“attendanceID”:237674,“attendeeUserID”:46114,“batchId”:1466,“departmentId”:null,“organizationId”:4,“leaveTypeId”:null, “attandanceType”:1,“absentDate”:“2017-06-12T00:00:00”,“评论”:
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”:“你的病房####是
今天缺席没有先前的信息。请寄信函 - ####“,”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中)
在android中执行此操作: