As others said:
Technically you don't need to parse anything because that already is a valid JSON object.
That seems to come from, maybe not properly, converted to JSON PHP object.
- In fact it seems to pretend to be a "real"⁽¹⁾ Array.
(1) Note that PHP call "Arrays" what in Javascript we call "Objects"
and, if they happen to only (or, at your own risk, even if not only)
contain numeric keys, they can be treated as "real" arrays.
So, by "real" array, I mean arrays having only numeric keys so they
can be converted to JSON arrays.
So I guess what you really want is to get an actual JSON array insetad of simple object.
If I'm right in that, possible solutions are:
SERVER SIDE (Best solution):
If you have chance, I would recommend to fix server side code instead.
I mean: If, as I guess, your data is expected to be a real array with only numeric keys, then convert to real JSON array.
But, in fact, this is what json_encode() php function is expected to do by default if possible:
<?php
echo json_encode(Array(1,2, 3, 4, "foo") . "\n");
// [1,2,3,4,"foo"]
echo json_encode(Array(1,2, 3, 4, "foo"=>"bar") . "\n");
// {"0":1,"1":2,"2":3,"3":4,"foo":"bar"}
So there should be some circumstance underneath that avoids it. Say:
Data has non numeric keys you haven't shown in your example.
- In that case you are forced to use that non-array form or make some more specific transformation (like ignoring keys and just consider object values).
Your PHP API isn't using json_encode() for conversion or is using (maybe as a generic pattern to avoid unconsistent response format if there can be results with or without non-numeric keys) JSON_FORCE_OBJECT modifier.
Example:
<?php
echo json_encode(Array(1,2, 3, 4, "foo"), JSON_FORCE_OBJECT) . "\n";
// {"0":1,"1":2,"2":3,"3":4,"4":"foo"
CLIENT SIDE:
On the other hand, if you can't (or, for any reason, you don't want to) modify server side code you can convert it back to an array with javascript client-side.
Example:
var foo = { 0: "2", 1: "JOHN", 2: "2147483647"};
console.log(Object.values(foo));
// [ '2', 'JOHN', '2147483647' ]