Majid
Majid

Reputation: 23

Removing root node in Json with multiple values

I have a json data stored in a variable.

Json Data:

var employees = {"emp":{{"firstName":"John"},{"secondName":"John"}}};

From above JSON Data, I should not have emp node. I need JSON Data as

{{"firstName":"John"},{"secondName":"John"}};

How can i remove using Javascript.

Upvotes: 0

Views: 341

Answers (1)

gurvinder372
gurvinder372

Reputation: 68413

if your employee object is

var employees = {"emp":{"firstName":"John","secondName":"John"}}; //since your original object is not correct

simply do

employees = employees.emp;

Upvotes: 3

Related Questions