我认为这是一个简单的问题,我之前没有像以前那样使用 JSON. 很简单,我有一个JSON对象: fc_json = { "product_count": 1,"total_price": 199.95,"total_weight": 1,"session_id": "26e8og4ldmlunj84uqf04l8l25", "custom_f
很简单,我有一个JSON对象:
fc_json = {
"product_count": 1,
"total_price": 199.95,
"total_weight": 1,
"session_id": "26e8og4ldmlunj84uqf04l8l25",
"custom_fields":{
"affiliateID":"25"
},
"messages":{
"errors":[],
"warnings":[],
"info":[]
}
};
我想用jQuery提取affiliateID的变量.有一个简单的方法吗?我真的不知道.
您不需要jQuery来访问JSON对象.实际上,JSON对象是一个JavaScript对象.你应该能做到的
alert(fc_json.custom_fields.affiliateID) // alerts 25
