2016-11-10 28 views
-3

「working_days」:[ { 「day_id」:2, 「從」:11, 「到」:22 }, { 「day_id」:3, 「從」:10, 「到」:23 } ],我怎樣才能通過凌空發佈此

那是劇本我需要張貼 我使用凌空用GSON的一部分,任何人可以幫助

{ 
    "userId": 2, 
    "token": "bdajkvnbadkvda1ad1fadf4ad5f1da5", 
    "name": "Center 123", 
    "address": "12 Ramsis Str.,", 
    "lat": "30.31194946131", 
    "long": "30.31194946131", 
    "location": "Assute", 
    "phone": "032365653232", 
    "owner_name": "Ahmed", 
    "owner_number": "164956465464", 
    "registry_number": "2161312", 
    "taxation_card": "2326-66321", 
    "contract_code": "1211132", 
    "remark": "Beside phrmacy", 
    "working_days": [ 
     { 
      "day_id": 2, 
      "from": 11, 
      "to": 22 
     }, 
     { 
      "day_id": 3, 
      "from": 10, 
      "to": 23 
     } 
    ], 
    "images": [ 
     { 
     "url": "uploads/center/s51fdf5df1d5.png" 
     }, 
     { 
     "url": "uploads/center/s5d1f6d645616.png" 
     } 
    ] 
    } 
+2

發佈您的代碼你到目前爲止 – Anjali

+1

做你嘗試任何的「解析JSON數據」的問題已經存在在這個網站嗎? – PeeHaa

+1

我投這個問題,因爲它是這個清單的副本http://stackoverflow.com/search?q=%5Bandroid-volley%5D+parse+json – PeeHaa

回答

0

您可以使用volley輕鬆解析您的響應。

try { 

      JSONObject jsonObject = new JSONObject(your_response); 
      int userId = jsonObject.getInt("userId"); 
      String token = jsonObject.getString("token"); 
          . 
          . 
          . 
          . 

      JSONArray working_days = jsonObject.getJSONArray("working_days"); 

      for (int i = 0; i < working_days.length(); i++) { 
         int day_id = jsonObject.getInt("day_id"); 
         int from = jsonObject.getInt("from"); 
         int to = jsonObject.getInt("to"); 
      } 


      JSONArray images = jsonObject.getJSONArray("images"); 

      for (int i = 0; i < working_days.length(); i++) { 
        int url = jsonObject.getInt("url"); 
      } 

     } catch (JSONException e) { 
      Log.e(TAG, "Your Boss is Calling"); 
     } 
+0

我需要發佈不解析抱歉,這是我的錯 –

+0

你需要在你的JsonObjectRequest中添加參數,試試這個http://stackoverflow.com/a/24988667/4199040 –