How to convert objects to Array of objects

kishore

My data

var data={
    key:value,
    key:value,
    key:value
};

Expected output

var data=[
    {key:value},
    {key:value},
    {key:value}
];
Sing

Simple for in loop is a way to handle this :

var data = {
    key:  'value',
    key1: 'value1',
    key2: 'value2'
};
var arr = []; 
for(var k in data){
    var o = {}; 
    o[k]=data[k]; 
    arr.push(o)
}
console.log(arr)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to convert object containing Objects into array of objects

How to convert JSON array to objects

how to convert object into array of objects (or collection of objects)

How to convert an array of custom objects to an array of strings?

How to convert objects containing array into object of objects

how to convert an array into a json array objects

How to convert an object into an array of objects?

How to convert array of objects to serialised?

How to convert array of objects into custom grouped array

How to convert array of objects to object of array in javascript?

How to convert ajax array of objects into array of arrays

How to convert an array of objects and arrays of objects to array of objects

How to convert 'n' objects into an Array

How to convert JavaScript array of objects into an array?

how to convert array of object with objects inside to array of objects

How to convert array of items to array of objects?

How to convert object into array of objects

how to convert string into array of objects

how to convert array into objects?

How to convert an Array of Objects into a single Objects

How to convert array of objects to array of arrays in javascript

How to convert the given object with objects to an array with objects

How to convert an array of objects to object

How to convert array of objects into array with changed positions

How to convert nested array of objects into one array of objects using javaScript?

How to convert array of array to array of objects in react

How to convert array of arrays to array of objects in javascript

how to convert string array of objects to array of objects

How to convert array to object in an array of objects