我的Json值是
{"candidateName":"Check","success":true,"candidateWorkExperience":"[{\"candidateWorkExperienceId\":7486,\"candidateBiographyRef\":{\"primaryKey\":98567,\"percent\":0.0,\"specialization\":0,\"rating\":0,\"description\":\"Check\",\"properties\":{},\"secondaryKey\":0,\"start\":0,\"limit\":0,\"noOfStud\":0,\"typingTest\":false,\"isPostGrad\":false},\"designation\":\"Check\",\"company\":\"Check\",\"startDate\":\"Jan 1, 2012\",\"endDate\":\"Jan 1, 2014\",\"workTypeMasterRef\":{\"primaryKey\":2,\"percent\":0.0,\"specialization\":0,\"rating\":0,\"description\":\"Permanent\",\"properties\":{},\"secondaryKey\":0,\"start\":0,\"limit\":0,\"noOfStud\":0,\"typingTest\":false,\"isPostGrad\":false},\"achivements\":\"Check\",\"candidateRecordStatus\":\"EXISTING\",\"currentCompany\":\"false\"}]"}
我试图通过
传递相同的内容JSONArray jarray = jsono.getJSONArray("candidateWorkExperience");
但我得到org.json.JSON.typeMismatch
例外。
任何人都可以建议如何将json数据加载到数组中。
答案 0 :(得分:2)
你的问题是你把js正在解释的“[]”解释为字符串而不是数组。
数组由[]括起,没有“。
尝试下一个json,让我知道这是否可以解决您的问题:
{
"candidateName": "Check",
"success": true,
"candidateWorkExperience": [
{
"candidateWorkExperienceId": 7486,
"candidateBiographyRef": {
"primaryKey": 98567,
"percent": 0.0,
"specialization": 0,
"rating": 0,
"description": "Check",
"properties": {
},
"secondaryKey": 0,
"start": 0,
"limit": 0,
"noOfStud": 0,
"typingTest": false,
"isPostGrad": false
},
"designation": "Check",
"company": "Check",
"startDate": "Jan1, 2012",
"endDate": "Jan1, 2014",
"workTypeMasterRef": {
"primaryKey": 2,
"percent": 0.0,
"specialization": 0,
"rating": 0,
"description": "Permanent",
"properties": {
},
"secondaryKey": 0,
"start": 0,
"limit": 0,
"noOfStud": 0,
"typingTest": false,
"isPostGrad": false
},
"achivements": "Check",
"candidateRecordStatus": "EXISTING",
"currentCompany": "false"
}
]
}
答案 1 :(得分:0)