解析我有這樣的Json以下哪我從.NET Web服務越來越:的Json不關鍵,Android的
[["Developer","test","[email protected]"]]
我jsonlint驗證檢查,這表明上述JSON罰款。
因爲它沒有任何key
我不知道如何解析它在Android中。 有人可以幫助我如何解析這個沒有密鑰的json。
如果有鑰匙,我會嘗試這樣做:
{"first":"somevalue","last":"someothervalue"} // Json response
JSONObject json_obj = new JSONObject(resp); //response is the json array
String first = json_obj.getString("first");
String last = json_obj.getString("last");
String test = "Hello! " + first + " " + last;
希望有人幫助:)
問候,
普利文
我的解決方案
JSONArray respo = new JSONArray(resp); //resp is Json Array
respo = respo.getJSONArray(0);
String test = respo.getString(2);
test = "Your Email Address is " + test;
它看起來像你的JSON是一個數組中的數組,所以第一個元素實際上來到包含整個數據集。我不熟悉Android如何處理這些,但但可以稍後檢查併發布答案(電話atm) –
那麼,如何在不使用'key'的情況下解析它? –
這不是響應中的JSON數組,它是一個String數組數組。 – thepoosh