我有json數據,我通過handlebars.js解析它 但是我得到的輸出不完全是應該在它的相同順序JSON。 的json代碼:Handlebars.js/JSON解析:從json解析的數據不是爲了
"RiskModel":{
"RiskModel":[
{
"ScoreFactors":{
"34":"Total of all balances on bankcard or revolving accounts is too high",
"12":"The date that you opened your oldest account is too recent",
"39":"Available credit on your open bankcard or revolving accounts is too low",
"04":"The balances on your accounts are too high compared to loan amounts"
}
}
]
}
我的HTML代碼:
{{#arf.RiskModel.RiskModel}}
{{#each ScoreFactors}}
<li>{{this}} </li>
{{/each }}
{{/arf.RiskModel.RiskModel}}
我的輸出如下所示:
THE DATE THAT YOU OPENED YOUR OLDEST ACCOUNT IS TOO RECENT
TOTAL OF ALL BALANCES ON BANKCARD OR REVOLVING ACCOUNTS IS TOO HIGH
AVAILABLE CREDIT ON YOUR OPEN BANKCARD OR REVOLVING ACCOUNTS IS TOO LOW
THE BALANCES ON YOUR ACCOUNTS ARE TOO HIGH COMPARED TO LOAN AMOUNTS
「12」 值被首先顯示,然後 「34」 值。
我不知道爲什麼。
我可以知道原因嗎?
我該如何解決這個問題?
您可以將JSON重構爲「ScoreFactors」:[{「Score」:「12」,「Text」:「some text」},{...},{...}]? – Chad
@Chad我從ajax調用中獲得這個json。 – JSnewbie
@Chad我如何重構JSON。你能幫我解決嗎? – JSnewbie