如何解析这个json数据?

时间:2014-10-21 12:19:59

标签: ajax json

任何人都可以解释一下我如何在json响应下解析。

这是我的功能

function supplierBelongings() {
            $.getJSON('accountpayble_getDataOnSuplierForInvoiceAdd.action', function(data) {
                alert(data);
                var data1 = data[0], data2 = data[1];
                alert(data1);
                alert(data2);
//                alert(data.currency.currencyName);
                //var splitVar = data.split(","); 
                //var data1 = data[0], data2 = data[1];
//                alert(splitVar[0]);
//                alert(splitVar[1]);
            });
        }

这是我的回复

 bothJson = [{"exchangeRateId":1,"currency":{"currencyId":1,"currencyName":"India","currencyCode":"INR","currencySymbol":"$","currencyDescription":"acfsf","currencySymbolPlace":"dvd"},"exchangeRateEffectiveDate":"Oct 18, 2014","exchangeRateValue":"20"},{"currencyId":1,"currencyName":"India","currencyCode":"INR","currencySymbol":"$","currencyDescription":"acfsf","currencySymbolPlace":"dvd"}]

1 个答案:

答案 0 :(得分:0)

您可以使用jquery解析JSON

var obj = jQuery.parseJSON( bothJson);
alert( obj.exchangeRateId === 1 );

如果你更具体地了解你想要的价值,我可以帮助你从这里深入了解。