I am trying to transform a JSON object to a javascript array, where the array would consist of the keys and values in the object. I have done it in different ways and I have not succeeded.
//Objeto Json
[
{dato: 'asdasd'},
{dato:'234234'}
]
The desired result would be something like this:
//Array
[
[dato, 'asdasd'],
[dato, '234234']
]
I have used the typeof
with different methods but always the result of this isobject
An easy way could be to iterate through your curly braces:
The result would be:
An easy option is to use a combination of:
Array.map()
, andObject.entries()
.With
objetoJson.map()
loops through each element of the array of objects, returning a value for each element of the array. WithObject.entries(elemento)
, you get an array with the key and value of each element, so you already have what you need.