2 a1003864169 a1003864169 于 2017.01.17 14:39 提问

安卓中解析socket获取的json时报错

在通过socket的获取的json数据,在拿json对应的数据是报错:at json of type java.lang.String cannot be converted to JSONObject。求大神指导
{"key":"tpgsg","json":"{\"T1\":[{\"GP\":\"GS\",\"GPID\":\"GS01\",\"GPName\":\"\u6897\u4E1D\u67DC01\",\"BatchID\":\"\",\"MATNAME\":\"\",\"GPInDateTime\":\"2017-1-6 15:4:32\",\"GPOutDateTime\":\"0-0-0 0:0:0\",\"GPInQty\":\"0.00\",\"GPQty\":\"0.00\",\"GPQtyP\":\"100.00\",\"GPTime\":\"0\",\"Status\":\"0.0\",\"GPStatus\":\"\u51FA\u67DC\u7ED3\u675F\"},{\"GP\":\"GS\",\"GPID\":\"GS02\",\"GPName\":\"\u6897\u4E1D\u67DC02\",\"BatchID\":\"\",\"MATNAME\":\"\",\"GPInDateTime\":\"2017-1-5 15:52:17\",\"GPOutDateTime\":\"2017-1-6 11:2:47\",\"GPInQty\":\"0.00\",\"GPQty\":\"0.00\",\"GPQtyP\":\"100.00\",\"GPTime\":\"0\",\"Status\":\"0.0\",\"GPStatus\":\"\u51FA\u67DC\u7ED3\u675F\"},{\"GP\":\"GS\",\"GPID\":\"GS03\",\"GPName\":\"\u6897\u4E1D\u67DC03\",\"BatchID\":\"\",\"MATNAME\":\"\",\"GPInDateTime\":\"2017-1-6 12:8:34\",\"GPOutDateTime\":\"0-0-0 0:0:0\",\"GPInQty\":\"0.00\",\"GPQty\":\"0.00\",\"GPQtyP\":\"100.00\",\"GPTime\":\"0\",\"Status\":\"0.0\",\"GPStatus\":\"\u51FA\u67DC\u7ED3\u675F\"},{\"GP\":\"GS\",\"GPID\":\"GS04\",\"GPName\":\"\u6897\u4E1D\u67DC04\",\"BatchID\":\"\",\"MATNAME\":\"\",\"GPInDateTime\":\"2017-1-6 7:45:22\",\"GPOutDateTime\":\"2017-1-6 13:55:39\",\"GPInQty\":\"0.00\",\"GPQty\":\"0.00\",\"GPQtyP\":\"100.00\",\"GPTime\":\"0\",\"Status\":\"0.0\",\"GPStatus\":\"\u51FA\u67DC\u7ED3\u675F\"},{\"GP\":\"GS\",\"GPID\":\"GS05\",\"GPName\":\"\u6897\u4E1D\u67DC05\",\"BatchID\":\"\",\"MATNAME\":\"\",\"GPInDateTime\":\"2017-1-6 9:33:34\",\"GPOutDateTime\":\"0-0-0 0:0:0\",\"GPInQty\":\"0.00\",\"GPQty\":\"0.00\",\"GPQtyP\":\"100.00\",\"GPTime\":\"0\",\"Status\":\"0.0\",\"GPStatus\":\"\u51FA\u67DC\u7ED3\u675F\"},{\"GP\":\"GS\",\"GPID\":\"GS06\",\"GPName\":\"\u6897\u4E1D\u67DC06\",\"BatchID\":\"\",\"MATNAME\":\"\",\"GPInDateTime\":\"2017-1-6 1:26:52\",\"GPOutDateTime\":\"2017-1-6 15:13:45\",\"GPInQty\":\"0.00\",\"GPQty\":\"0.00\",\"GPQtyP\":\"100.00\",\"GPTime\":\"0\",\"Status\":\"0.0\",\"GPStatus\":\"\u51FA\u67DC\u7ED3\u675F\"},{\"GP\":\"GS\",\"GPID\":\"GS07\",\"GPName\":\"\u6897\u4E1D\u67DC07\",\"BatchID\":\"\",\"MATNAME\":\"\",\"GPInDateTime\":\"2017-1-6 5:33:13\",\"GPOutDateTime\":\"2017-1-6 7:41:17\",\"GPInQty\":\"0.00\",\"GPQty\":\"0.00\",\"GPQtyP\":\"100.00\",\"GPTime\":\"0\",\"Status\":\"0.0\",\"GPStatus\":\"\u51FA\u67DC\u7ED3\u675F\"},{\"GP\":\"GS\",\"GPID\":\"GS08\",\"GPName\":\"\u6897\u4E1D\u67DC08\",\"BatchID\":\"\",\"MATNAME\":\"\",\"GPInDateTime\":\"2017-1-5 1:34:41\",\"GPOutDateTime\":\"2017-1-5 2:46:20\",\"GPInQty\":\"0.00\",\"GPQty\":\"0.00\",\"GPQtyP\":\"100.00\",\"GPTime\":\"0\",\"Status\":\"0.0\",\"GPStatus\":\"\u51FA\u67DC\u7ED3\u675F\"}]}"}

3个回答

Royal_lr
Royal_lr   Ds   Rxr 2017.01.17 15:01

string不能被转成jsonObject,,json对象

u013322594
u013322594   2017.01.18 17:56

传过来的json是String类型的,不能转成JsonObject

u013322594
u013322594   2017.01.18 18:01

JsonObject result=new JsonObject(result);
String json=result.getString("json");
JsonObject jo=new JsonObject(json);

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!