07-24-2023, 06:35 AM
I want to parse a JSON Object into an two dimensional array. But my code don't work.
Here my example:
```
{
"test":[
{
"id": 1,
"first_name": "Robert",
"last_name": "Schwartz",
"email": "[email protected]"
},
{
"id": 2,
"first_name": "Lucy",
"last_name": "Ballmer",
"email": "[email protected]"
},
{
"id": 3,
"first_name": "Anna",
"last_name": "Smith",
"email": "[email protected]"
}
]
};
var as = JSON.parse(test);
console.log(as)
```
I thought an normalized array I can parse with the parse function. But it don't work.
The result array should be like that:
```
[[1,"Robert","Schwartz","[email protected]"],[2,"Lucy","Ballmer","[email protected]"],[3,"Anna","Smith", "[email protected]"]]
```
Thank you for all solutions.
Here my example:
```
{
"test":[
{
"id": 1,
"first_name": "Robert",
"last_name": "Schwartz",
"email": "[email protected]"
},
{
"id": 2,
"first_name": "Lucy",
"last_name": "Ballmer",
"email": "[email protected]"
},
{
"id": 3,
"first_name": "Anna",
"last_name": "Smith",
"email": "[email protected]"
}
]
};
var as = JSON.parse(test);
console.log(as)
```
I thought an normalized array I can parse with the parse function. But it don't work.
The result array should be like that:
```
[[1,"Robert","Schwartz","[email protected]"],[2,"Lucy","Ballmer","[email protected]"],[3,"Anna","Smith", "[email protected]"]]
```
Thank you for all solutions.