can a JSON start with [? -


from can read on json.org, json strings should start { (curly brace), , [ characters (square brackets) represent array element in json.

i use json4j library, , got input starts [, didn't think valid json. looked briefly @ json schema, couldn't find stated json file cannot start [, or can start {.

json can either array or object. off of json.org:

json built on 2 structures:

  • a collection of name/value pairs. in various languages, realized object, record, struct, dictionary, hash table, keyed list, or associative array.
  • an ordered list of values. in languages, realized an
    array, vector, list, or sequence.

it goes on describe 2 structures as: a json object a json array

note starting , ending characters curly brackets , square brackets respectively.

edit
, here: http://www.ietf.org/rfc/rfc4627.txt

a json text sequence of tokens. set of tokens includes 6 structural characters, strings, numbers, , 3 literal names.

a json text serialized object or array.

update (2014)

as of march 2014, there new json rfc (7159) modifies definition (see pages 4/5).

the definition per rfc 4627 was: json-text = object / array

this has been changed in rfc 7159 to: json-text = ws value ws

where ws represents whitespace , value defined follows:

a json value must object, array, number, or string, or 1 of following 3 literal names:

false null true 

so, answer question still yes, json text can start square bracket (i.e. array). in addition objects , arrays, can number, string or values false, null or true.

also, has changed previous rfc 4627 quote (emphasis added):

a json text sequence of tokens. set of tokens includes 6 structural characters, strings, numbers, , 3 literal names.

a json text serialized value. note previous specifications of json constrained json text object or array. implementations generate objects or arrays json text called interoperable in sense implementations accept these conforming json texts.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -