2016-08-19 14 views
-6

私は以下のjson文字列を持っていますが、解析できません。誰も助けることができます。前もって感謝します。jsonの文字列にキー名がない場合、Gsonを使ってjsonを解析できません

{ 
    [ 
    {"transaction_name" : "total_fare", "unit" : "Rs", "label" : "Bill Amount", "value" : 250, "additional_details" : "4 Rides"}, 
    {"transaction_name" : "incentives", "label" : "Incentives", "value" : 50, "additional_details" : ""}, 
    {"transaction_name" : "fees", "label" : "Fees", "value" : -20, "additional_details" : "Rs 5 on each ride"}, 
    {"transaction_name" : "device_deduction", "label" : "Device Deduction", "value" : -20, "additional_details" : ""}, 
    {"transaction_name" : "tax", "label" : "Device Deduction", "value" : -20, "additional_details" : ""}, 
    {"transaction_name" : "device_deduction", "label" : "Device Deduction", "value" : -20, "additional_details" : ""}] 
    ], 
    "footer" : 
    { 
     "transaction_name" : "total_earning_net", "label" : "Total Earnings", "value" : 200, 
     "additional_details" : "Rounding Off" 
    } 
} 
+0

、あなたのJSONArrayへの鍵を与えることをしようと、間違っています。 [MCVE]とhttp://stackoverflow.com/help/how-to-askを参照してください。 – pvg

+0

@pvg私は正しいコードを書くことができません。内側のjson配列にキーがないので、私は問題に直面しています。 –

+0

JSON文字列が有効なJSONではありません。キーはどこですか? –

答えて

0

あなたのJSON自体は、あなたがして解析しようとしているコードを、あなたが直面している特定のエラーを提供しなければならない

{ 
"data": [{ 
    "transaction_name": "total_fare", 
    "unit": "Rs", 
    "label": "Bill Amount", 
    "value": 250, 
    "additional_details": "4 Rides" 
}, { 
    "transaction_name": "incentives", 
    "label": "Incentives", 
    "value": 50, 
    "additional_details": "" 
}, { 
    "transaction_name": "fees", 
    "label": "Fees", 
    "value": -20, 
    "additional_details": "Rs 5 on each ride" 
}, { 
    "transaction_name": "device_deduction", 
    "label": "Device Deduction", 
    "value": -20, 
    "additional_details": "" 
}, { 
    "transaction_name": "tax", 
    "label": "Device Deduction", 
    "value": -20, 
    "additional_details": "" 
}, { 
    "transaction_name": "device_deduction", 
    "label": "Device Deduction", 
    "value": -20, 
    "additional_details": "" 
}], 
"footer": { 
    "transaction_name": "total_earning_net", 
    "label": "Total Earnings", 
    "value": 200, 
    "additional_details": "Rounding Off" 
    } 

} 
関連する問題