[英]Splitting JSON data into two separate arrays
我正在嘗試使用JSON網址並將所有信息處理為兩個單獨的數組。 數據上的第一個數組以“ output_no_match”開頭,第二個數組的格式相同,以“ avalanche_with_match”開頭。 我陷入了如何將數據准確地分成兩個單獨的數組然后進行處理(並放入圖形中)的問題。
謝謝你的幫助!
[{"date":"2014-12-01T00:00:00-06:00"
"id":null
"balance":915047.12
"interest":710669475.15
"interest_paid":10199.29
"ending_principal_balance":915047.12
"ending_interest_balance":710659275.86
"payment_due":10199.29}
假設您有一個位於http://your-host.com/sampleData.json的文件,其中包含您的JSON數據:
{"output_no_match": [{
"date": "2014-12-01T00:00:00-06:00",
"id": null,
"balance": 915047.12,
"interest": 710669475.15,
"interest_paid": 10199.29,
"ending_principal_balance": 915047.12,
"ending_interest_balance": 710659275.86,
"payment_due": 10199.29
}],
"avalanche_with_match": [{
"date": "2014-12-01T00:00:00-06:00",
"id": null,
"balance": 915047.12,
"interest": 710669475.15,
"interest_paid": 10199.29,
"ending_principal_balance": 915047.12,
"ending_interest_balance": 710659275.86,
"payment_due": 10199.29
}]},
那么您可以使用XMLHttpRequest(使用jQuery)來獲取它:
$.get('http://your-host/sampleData.json').success(function(data){
//data is js object with your arrays
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.