weixin_33733810 2014-10-21 04:19 采纳率: 0%
浏览 29

如何解析这个JSON数据?

Can anyone please explain me how can I parse below json response .

this is my function

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]);
            });
        }

This is my response

 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条回答 默认 最新

  • weixin_33739541 2014-10-21 04:25
    关注

    You can use jquery's parse JSON

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

    If you are more specific on which value you want I can help drill down from here.

    评论
编辑
预览

报告相同问题?