Do you consider the JSON web response:
"A serialization error occurred"
to be valid or not?
Some validators accept it while others don't.
Do you consider the JSON web response:
"A serialization error occurred"
to be valid or not?
Some validators accept it while others don't.
As for new JSON RFC, json, containing only single value is pretty valid.
A JSON text is a serialized value. Note that certain previous specifications of JSON constrained a JSON text to be an object or an array.
There's a change of heart on this between RFC4627 and RFC7159:
RFC4627:
A JSON text is a serialized object or array.
JSON-text = object / array
RFC7159:
A JSON text is a serialized value. Note that certain previous
specifications of JSON constrained a JSON text to be an object or an
array. Implementations that generate only objects or arrays where a
JSON text is called for will be interoperable in the sense that all
implementations will accept these as conforming JSON texts.JSON-text = ws value ws
No philosophical or practical justification is provided for this change of heart. The earlier version probably makes more sense as it consistently dictates that both a singe list element and a single map element (a pair or tuple) be contained. The second version allows only a single list element to be uncontained.
According to the grammar exposed in http://www.json.org/ (which references the Standard ECMA-262 3rd Edition - December 1999 par.5.1.5 The JSON Grammar) it's wrong:
The initial element must be:
and then a value can be a string:
I don't care if some validator accepts it. It's wrong. It's a question of good practice, Json format must be {"key": "value", .....}
. If you consider that text Json, can work, but for the rest of programmer it's not a serious Json. If you use only that text, then you don't need Json.