如何解析这个?

时间:2012-08-13 15:24:07

标签: android json parsing arrays

朋友请帮我解析使用Json对象和json数组概念的响应 我将所有字段作为字符串显示

{"status": "OK", 
 "data": {
       "passenger": [
               {"status": "S2 , 26", 
               "seat_number": "RAC 53,GNWL"}, 
               {"status": "S2 , 27", "seat_number": "RAC 54,GNWL"}], 
       "from": {"code": "MAQ", 
               "name": "MANGALORE", 
               "time": "14:40"}, 
       "chart_prepared": true, 
       "alight": 
               {"code": "LTT", 
               "name": "LOKMANYA TILAK (T)", 
               "time": "06:35"}, 
       "pnr_number": "4243907794", 
       "train_number": "12620", 
       "to":   {"code": "LTT", 
               "name": "LOKMANYA TILAK (T)", 
               "time": "06:35"}, 
       "board": {"timestamp": 1344849000, 
               "code": "MAQ", 
               "name": "MANGALORE", 
               "time": "14:40"}, 
       "train_name": "MATSYAGANDA EXP", 
       "travel_date": {"date": "13-8-2012", 
               "timestamp": 1344796200}, 
       "class": "SL"
       }
 }

2 个答案:

答案 0 :(得分:0)

您可以使用http://www.json.org/java/,以字符串作为第一个参数来实例化一个新的JSONObject,并从那里继续。

答案 1 :(得分:0)

这里是你JSON结构的上图 enter image description here

你应该更好地使用http://jsonviewer.stack.hu/并在这里粘贴你的json来查看和理解它的结构,然后可以使用GSON或任何其他库来解析它并从中得到你想要的东西