【问题标题】:Json get data valueJson获取数据值
【发布时间】:2018-03-18 23:00:00
【问题描述】:

我只需要获取 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解码

o/p: register.id

【问题讨论】:

  • 请描述您的问题
  • 我想在jquery中解码上面的json对象
  • Parse Json data in Jquery的可能重复
  • 你在用 ajax() 吗

标签: php jquery json


【解决方案1】:

请试试这个:

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

【讨论】:

    【解决方案2】:
    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
    

    【讨论】:

      猜你喜欢
      • 2015-01-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-07
      • 2019-03-30
      相关资源
      最近更新 更多