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
Post a Comment