Sunday, 24 September 2017

javascript - Remove a JSON attribute





if I have a JSON object say:



var myObj = {'test' : {'key1' : 'value', 'key2': 'value'}}


can I remove 'key1' so it becomes:



{'test' : {'key2': 'value'}}

Answer




Simple:



delete myObj.test.key1;

No comments:

Post a Comment

casting - Why wasn't Tobey Maguire in The Amazing Spider-Man? - Movies & TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...