2017-06-12 34 views
-1

我想知道是否有任何方式可以接收JsonArray作爲來自發布請求的回覆。問題是我的回答是一個JSONObject類型。我知道如何從String類型響應中得到響應,我想知道從JSONObject類型響應中獲得響應的方法。接收JsonArray作爲來自發布請求的回覆

這是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 
} 

回答

-1

你總是可以解析爲json。但首先要正確格式化該字符串:

[ { 「attendanceID」:237674, 「attendeeUserID」:46114, 「batchId」:1466, 「DepartmentID的」:空, 「organizationId」:4,「leaveTypeId 「:null, 」attandanceType「:1,」absentDate「:」2017-06-12T00:00:00「,」comment「:
null,」subjectId「:null,」isAbsent「:true,」markedBy「 :2780,
「請將isDeleted」:假 「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系統:

Already answered here

相關問題