2015-12-17 49 views
-1

我想知道如何通過j兒子獲取數據。 I.我是這樣創建的,但沒有得到任何數據?如何通過jsons獲取數據?

"arr": [1] 
0: { 
"obj": { 
"id": "24" 
"dispensary_id": "24" 
"item_name": "item 3" 
"total_feedback": "1" 
"total_item": "13" 
"followers": "7" 
"follow_status": "following" 
"category": "Edibles" 
"strain": "Indica" 
"tch": "0.70" 
"cbd": "13.30" 
"description": "testing items" 
"image": "1447508911_greenfeed-3.jpg" 
"qty1": "1/8 OZ" 
"price1": "100" 
"qty2": "1/4 OZ" 
"price2": "200" 
"qty3": "1/2 OZ" 
"price3": "400" 
"qty4": "1 OZ" 
"price4": "799" 
"dispensary_first_name": "Acme Dispensary" 
"dispensary_last_name": "Smith" 
"company": "Acme Dispensary" 
"dispensary_image": "1449182412.png" 
"city": "Irvine" 
"state": "CA" 
"status": "1" 
}- 
}- 
- 
"result": "true" 
} 
+0

你的代碼獲取數據在哪裏? –

+0

你的JSON無效 –

+0

但是當我在郵遞員看到這是這樣的: - –

回答

0

您JOSN格式錯了,它應該是這樣的

{ 
    "obj": { 
     "id": "24", 
     "dispensary_id": "24", 
     "item_name": "item 3", 
     "total_feedback": "1", 
     "total_item": "13", 
     "followers": "7", 
     "follow_status": "following", 
     "category": "Edibles", 
     "strain": "Indica", 
     "tch": "0.70", 
     "cbd": "13.30", 
     "description": "testing items", 
     "image": "1447508911_greenfeed-3.jpg", 
     "qty1": "1/8 OZ", 
     "price1": "100", 
     "qty2": "1/4 OZ", 
     "price2": "200", 
     "qty3": "1/2 OZ", 
     "price3": "400", 
     "qty4": "1 OZ", 
     "price4": "799", 
     "dispensary_first_name": "Acme Dispensary", 
     "dispensary_last_name": "Smith", 
     "company": "Acme Dispensary", 
     "dispensary_image": "1449182412.png", 
     "city": "Irvine", 
     "state": "CA", 
     "status": "1" 
    } 
} 

對於這一點,你可以檢查你的JSON是否有效與否http://jsonlint.com/

用於創建json,你可以使用一些庫,如

JSONObject jsonObject = new JSONObject(); 
jsonObject.add("key", "value"); 
jsonObject.add("key", "value");