Friday, March 7, 2014

New JSON standard passes the buck

There is a new JSON standard out. It contains a few interesting things. For example, here is one change noted in the changelog:
Changed the definition of "JSON text" so that it can be any JSON value, removing the constraint that it be an object or array.
This is consistent with what Postgres does, but we actually had a bit of a debate back when we implemented JSON about whether or not it was the right thing to do. Maybe it wasn't then but is now :-)

And there this is this delightful couple of new paragraphs:
An object whose names are all unique is interoperable in the sense that all software implementations receiving that object will agree on the name-value mappings. When the names within an object are not unique, the behavior of software that receives such an object is unpredictable. Many implementations report the last name/value pair only. Other implementations report an error or fail to parse the object, and some implementations report all of the name/value pairs, including duplicates.
JSON parsing libraries have been observed to differ as to whether or not they make the ordering of object members visible to calling software. Implementations whose behavior does not depend on member ordering will be interoperable in the sense that they will not be affected by these differences.
How is that for having it both ways? You might not be incorrect if you allow duplicate names or if your application relies on object member ordering, just not "interoperable." Once, RFCs laid down the law, now they just seem to codify existing, possibly "non-interoperable" practice.

2 comments:

  1. Actually, they have always codified existing practice. Postel’s Law, that famous phrase whose premise makes little sense if you think in terms of The Law, is a quote from RFC 761 – back in 1980. If you look at the email RFCs you will see plenty of “implementations have been observed to do X”-type advice, and the HTTP RFCs are not far behind. The very fact that RFC 2119 exists is down to this mentality. Good standardisation is codification of existing practice.

    ReplyDelete
  2. I know, you're right of course. I was just rather sad to see them codifying what I consider to be badly broken.

    ReplyDelete