我从API
获取JSONObject{
"contact": null,
"error": false,
"msg": "get Contacts successfully",
"synccontactstimestamp": "2018-02-07 11:34:40.0",
"contactjson": "[{\"contactName\":\"4B9B4474C091D55A981ADBB7893FB4E1\",\"contactNumber\":\"0F8F3E9514D329F32CE7B03B9D276D72\"}, {\"contactName\":\"12E09C05C0E456AC2398BDA841986609\",\"contactNumber\":\"035774DB94BFE24BDEDA0B4B45F1372A0CC8EE72A457C3AAA35F79627FD13728\"}, {\"contactName\":\"9344BBF08ACACC4C85A9B83C55BA93C0\",\"contactNumber\":\"E1633601A6632356DB2F08058CA42504\"}, {\"contactName\":\"CCF51D9C27123ACD19F163F6C2BCCD28\",\"contactNumber\":\"89DD6C0E185D1067AC45CEE12DFA6A07\"}, {\"contactName\":\"A8309A8EC81E4DF50306FE4651D63F53\",\"contactNumber\":\"E8781EE87E9036B794BE44D7411FBFCF\"}
我正在尝试使用键“contactjson”获取此JSONArray,但它提供了一个例外
Value of string type cannot be converted to JSONArray.
知道如何获取这个吗?
答案 0 :(得分:1)
如您所见, contactjson 键的值将以字符串,
显示首先将您的contactjson转换为像
这样的String变量 String data = yourResponse.contactjson;
然后转换为JSONArray
JSONArray jsonArr = new JSONArray(data);