javascript - How to get a piece of an json object with its parent node? -


how can part of object including parent node?

complete string objet:

var big = '{ "offline": { "more"  : "content"  },               "online":  { "more1" : "content1" },              "extra":   { "more2" : "content2" }  }'; alert( json.parse( big ) ); 

i want in new object:

var part = '{ "offline": { "more"  : "content"  }}'; 

i have no success : json.parse( big ).offline

because containing: '{ "more" : "content" }'

instead of'{ "offline": { "more" : "content" }}'

json.stringify convert oject string. try this:

var big = '{ "offline": { "more"  : "content"  }, "online":  { "more1" : "content1" },"extra":   { "more2" : "content2" }  }';  var newobject = {    offline: json.parse(big).offline  }  alert(json.stringify(newobject));


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -