Today it became a discovery for me that even a string of the form:

$json = '[["test2", "test2"], "yo1", ["message1", "msg2", ["bing1", "bang", "oops"], "msg3"]]'; 

calmly using

 json_decode($json); 

converted to a regular array:

 Array ( [0] => Array ( [0] => test2 [1] => test2 ) [1] => yo1 [2] => Array ( [0] => message1 [1] =>; msg2 [2] => Array ( [0] => bing1 [1] => bang [2] => oops ) [3] => msg3 ) ) 

How can this be? Due to what?

    1 answer 1

    The string you give in the example fully satisfies the specifications.

    JSON is built on two structures:

    • A collection of name / value pairs. In various languages, this is a record, struct, dictionary, hash table, keyed list, or associative array.

    • An ordered list of values. As an array , vector, list, or sequence.

    ... An array is an ordered collection of values. An array begins with [(left bracket) and ends with] (right bracket). Values ​​are separated by, (comma).

    A number of quotes, or a number , or a true or false or null, or an object . These structures can be nested.

    Original article

    Transfer:

    JSON is built on two structures.

    • A collection of key / value pairs. In different languages, this concept is implemented as an object , record, structure, dictionary, hash, named list, or associative array.
    • An ordered list of values. In most languages, this is implemented as an array , vector, list, or sequence.

    ... array is an ordered collection of values. The array begins with [(the opening square bracket) and ends with] (the closing square bracket). Values ​​are separated, (comma).

    The value can be a string in double quotes, a number , true, false, null, an object or an array . These structures can be nested.

    Original article

    Thus, in the string we have an array, the first element of which is another array, both of which are the strings "test2" and "test2", the next element is the string "yo1", and so on.

    • because This Stack Overflow in Russian , the translation does not hurt. - Alex
    • json.org/json-ru.html =) - Vladimirov Alexey
    • but links are not welcome - Alex
    • one
      Now I will correct the answer, I did not think. - Vladimirov Alexey
    • one
      Thanks for formatting, and edits. I will consider - Vladimirov Alexey