How to convert multidimensional array to json and back?

Good day, first time faced with the JSON and a lot of things not clear..
Now, suppose we have a multidimensional array in php:
 array(22) {
 string(2) "58"

 string(11) "Tula"
 array(22) {
 string(2) "59"

 string(11) "G. Тула1

From a php script and send it back to ajax echo json_encode($array);

And when you do console.log(data), it turns out that came to an object, not an array, but I would like an array...
And, frankly, I do not understand how to access its elements.


var b = $.parseJSON(data);
console.log(b.ID) // gives nothing...
July 8th 19 at 16:48
1 answer
July 8th 19 at 16:50
You get just an array, inside of which lies a single object: [Object]
Accordingly, it is necessary to do so: console.log(b[0].ID)

Find more questions by tags JavaScriptPHP