-1

I need to get only id data

{"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"}}

need to do jquery json decode

o/p: register.id

Pritamkumar
  • 682
  • 1
  • 11
  • 30

2 Answers2

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

enter image description here

Ajay Kumar
  • 1,314
  • 12
  • 22
Vision Coderz
  • 8,257
  • 5
  • 41
  • 57
0

Please try this one:

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']);
kkakkurt
  • 2,790
  • 1
  • 30
  • 33