RainingChain RainingChain - 6 months ago 8
JSON Question

JSON Attribute Best Practice

Usually, what I see is

{"attribute":241241}


but writting this does exactly the same thing :
{attribute:241241}
.

Is
{attribute:241241}
considered bad practice and should be avoided or not?

Answer

{attribute:241241} does not validate using JSONLint, so yes, it is bad practice and should be avoided.

Further, if you look at the JSON spec at json.org, you will find that for objects the first value is always a string (indicated by double quotes).

Comments