嵌套JSON數據我有這樣的JSON數據:得到的jQuery
[{"sequence":"503","accountnumber":"0001","telephonenumber":null,"emailaddress":"[email protected]","directdebit":"Y","auto_directdebit":"","billing_address":{"title":"Mr","forename":"Joe","surname":" Bloggs","address1":"ADDR1","address2":"","address3":"","town":"TOWN","county":"COUNTY","postcode":"PC","country":"United Kingdom","default_invoice":"1","default_delivery":"1"}}]
我使用以下方法來獲取詳細信息:
$.ajax({
type: "GET",
url: "/section/get_data?getCustomer=1&sequence=" + $("#customersequence").val(),
data: $(this).serialize(),
success: function(data) {
alert(data[0].accountnumber);
}
});
其工作,但我無法弄清楚如何返回billing_address
我曾嘗試:
data[0].billing_address[0].address1
但沒有奏效
我怎麼能下billing_address
'數據[0] .billing_address'是* *對象與屬性'address1'。 –
解析JSON,當它返回數據時,它是純字符串而不是JSON對象 –
@Luminous_Dev技術說明:JSON是代表序列化對象圖的*純文本*。 JavaScript對象不是JSON。 – user2864740