如何将包含键值对的对象转换为JavaScript中的对象数组

时间:2017-11-02 13:22:23

标签: json

任何人都可以帮我解决这个问题吗? 我有JSON对象,如下所示

[
    {"app_Welcome": "Welcome"},
    {"app_Notifications": "Notifications"},
    {"app_New": "New"}
]

我希望将其转换为对象数组

{{1}}

谢谢!

1 个答案:

答案 0 :(得分:-1)



    var a = {
        "app_Welcome": "Welcome",
        "app_Notifications": "Notifications",
        "app_New": "New"
    };

    var result = [];
    for( var property in a) {
        var obj = {};
        obj[property] = a[property];
        result.push( obj ); 
    }
    
    console.log(result);




相关问题