我只需要获取id数据
{"register":{"id":"1","members_count":null,"name":"Neha","user_name":"Neha","email":"help.eduexpression.com@gmail.com","profileId":"8866","maritialstatus_id":"1","religion_id":"1","caste_id":null,"mothertongue_id":"4","employed_id":"6","country_id":"103"}}
需要做jquery json decode
o / p:register.id
答案 0 :(得分:3)
var jsondata='{"register":{"id":"1","members_count":null,"name":"Neha","user_name":"Neha","email":"help.eduexpression.com@gmail.com","profileId":"8866","maritialstatus_id":"1","religion_id":"1","caste_id":null,"mothertongue_id":"4","employed_id":"6","country_id":"103"}}';
var result=$.parseJSON(jsondata);
// OR
var result=JSON.parse(jsondata);
console.log(result.register.id); //result will be 1
答案 1 :(得分:0)
请尝试这个:
var obj ='{"register":{"id":"1","members_count":null,"name":"Neha","user_name":"Neha","email":"help.eduexpression.com@gmail.com","profileId":"8866","maritialstatus_id":"1","religion_id":"1","caste_id":null,"mothertongue_id":"4","employed_id":"6","country_id":"103"}}';
var json = JSON.parse(obj);
alert(json.register['id']);