从数组中获取json键值对

时间:2014-09-11 11:11:27

标签: android

{"work":[{"position":{},"employer":{},"start_date":"2014-01-11","location":{}},{}}],"hometown":{""},"location":{},"locale":"en_GB","link":"https:\/\/www.facebook.com\/profile.php?id=100002375124798","education":[],"updated_time":"2014-01-20T17:28:10+0000","id":"100002375124798","first_name":"Faizan","timezone":5,"quotes":"The one who loves u is going to hurt from you bcz its a life yahan sub ahsa he hota ha.........","verified":true,"name":"Faizan Khan","last_name":"Khan","gender":"male"}

这是我的json怎样才能从这里得到first_name,last_name,性别,我也得到了jinobrin的json,但是我无法获得keyvalue对之上的颜色?

1 个答案:

答案 0 :(得分:0)

您的JSON格式无效。如果你有正确的JSON,你可以这样做:

String myJSON = ...
//Here we construct a JSONObject, because it makes handling JSON formatted Strings much 
//easier than having them in plain String format
JSONObject jObj = new JSONObject(myJSON);
String first_name = jObj.getString(first_name);