Android 从post请求接收JsonArray作为响应
我想知道是否有任何方法可以从post请求接收Android 从post请求接收JsonArray作为响应,android,Android,我想知道是否有任何方法可以从post请求接收JsonArray作为响应。问题是我的回答是JSONObject类型。我知道如何从字符串类型响应获取响应,我想知道从JSONObjecttype响应获取响应的方法 这是我想要得到的JSONArray响应 { "attendanceID": 237674, "attendeeUserID": 46114, "batchId": 1466, "departmentId": null, "organizationId"
JsonArray
作为响应。问题是我的回答是JSONObject
类型。我知道如何从字符串类型响应获取响应,我想知道从JSONObject
type响应获取响应的方法
这是我想要得到的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,“AttendeUserId”:46114,“batchId”:1466,“departmentId”:null,“organizationId”:4,“leaveTypeId”:null, “附件类型”:1,“缺席日期”:“2017-06-12T00:00:00”,“评论”:
空,“主观性”:空,“isAbsent”:真,“markedBy”:2780,
“isDeleted”:false,“dateTimeStampIns”:
“2017-06-12T13:11:50.9457068+05:30”,“日期时间戳”:
“2017-06-12T13:11:50.9457068+05:30”,“附件名称”:空,
“businessDays”:0,“templateId”:1,“message”:“您的病房是
今天缺席,没有事先通知。请发送请假信- ####“,“message1”:null,“isHalfDay”:null},{//这将是第二行“attendanceID”:455435,“AttendeUserId”: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中实现这一点: