Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Valid JSON without brackets and IDs?

Tags:

json

This is a theoretical question. Just wondering why the following is a valid JSON

[12,"json",true]

There is any answer about that?

like image 423
Manos Kirtas Avatar asked Jun 10 '26 09:06

Manos Kirtas


2 Answers

THat's a JSON array. According to the latest specification, all of the following are valid JSON (1 per line):

123
"string"
null
true
false
["array item 1", 123]
{ "property": "value" }
like image 75
Evert Avatar answered Jun 11 '26 23:06

Evert


From json.org

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 value can be a string in double quotes, or a number, or true or false or null, or an object or an array. These structures can be nested.

Hence [12,"json",true] is a valid json.

like image 30
Riyafa Abdul Hameed Avatar answered Jun 11 '26 22:06

Riyafa Abdul Hameed