当前位置: 动力学知识库 > 问答 > 编程问答 >

javascript - 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.

网友答案:

if your employee object is

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

simply do

employees = employees.emp;
分享给朋友:
您可能感兴趣的文章:
随机阅读: