0

Can anyone help me on on this? I have JSON object as below

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

and I want to convert it to to an array of object

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

Thanks!

1 Answers1

-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);
YouneL
  • 8,152
  • 2
  • 28
  • 50