次のような JSON データがあります。
var data = '{"credit":{"@code":"NT2C8FFC","card":"NT2C8FFC","credit":"149.96","amount":"149.96","disabled":"0","expired":"2011-02-15 10:21:18","user":"xxxx","issued":"2010-02-15 10:21:18","orderid":[],"fromorder":[],"email":"xxxx","phone":[],"state":[],"address":[],"city":[],"zip":[],"country":[],"customerid":"xxx","order":"xxx","order_date":"2010-01-23 00:00:00","reason":"Product Not Working as Expected","source":"xxx","first":[],"last":[],"notes":[]}}'
実際にはJSONとして返されています。ここでは例としてこのように表示しています。data["credit"]
呼び出された要素を取得するために使用できますcredit
が、それは私だけを取得します:
{"@code":"NT2C8FFC","card":"NT2C8FFC","credit":"149.96","amount":"149.96","disabled":"0","expired":"2011-02-15 10:21:18","user":"xxxx","issued":"2010-02-15 10:21:18","orderid":[],"fromorder":[],"email":"xxxx","phone":[],"state":[],"address":[],"city":[],"zip":[],"country":[],"customerid":"xxx","order":"xxx","order_date":"2010-01-23 00:00:00","reason":"Product Not Working as Expected","source":"xxx","first":[],"last":[],"notes":[]}
1 つのショットにドリルダウンするにはどうすればよいですか? data["credit"]["credit"]
は適切な構文ではありません。未定義になります。近くにいることは知っていますが、残りは思い出せません。目標は149.96
、JSON データから取得することです。