访问JSON响应中的JSON值



我有一个下拉列表,有一个onchange()函数,它调用一个指向控制器中某个函数的ajax请求。

我想打印所有的值,比如client_address,它会像那样打印"都灵"。我想要javascript。

"billing_details":
{"{contact_firstname}":"Luis",
"{contact_lastname}":"Garcia",
"{contact_email}":"lg@gmail.com",
"{client_company}":null,
"{client_phonenumber}":"1234566",
"{client_country}":"French Southern Territories",
"{client_city}":"Venis",
"{client_zip}":"13212",
"{client_state}":"Djbouti",
"{client_address}":"Turin",
"{password}":"",
"{client_building_no}":"12",
"{client_country_id}":"79",
"{client_calling_code}":"262",
"{client_id}":"25",
"{country_short}":"TF"}}

您可以通过obj['key']访问值

var data={"billing_details":{
"{contact_firstname}":"Luis",
"{contact_lastname}":"Garcia",
"{contact_email}":"lg@gmail.com",
"{client_company}":null,
"{client_phonenumber}":"1234566",
"{client_country}":"French Southern Territories",
"{client_city}":"Venis",
"{client_zip}":"13212",
"{client_state}":"Djbouti",
"{client_address}":"Turin",
"{password}":"",
"{client_building_no}":"12",
"{client_country_id}":"79",
"{client_calling_code}":"262",
"{client_id}":"25",
"{country_short}":"TF"}}
console.log(data.billing_details['{client_address}'])

相关内容

  • 没有找到相关文章

最新更新