ubjson / universal-binary-json

Community workspace for the Universal Binary JSON Specification.
116 stars 12 forks source link

Ensure examples on UBJSON.org are valid JSON-compatible constructs #15

Closed ghost closed 10 years ago

ghost commented 12 years ago

Marco Costa wrote in to point out that some of the examples I put in the UBJSON spec doc are not valid JSON. These examples all have to be valid JSON as 1:1 compatibility is the big selling point of UBJSON, there is no reason to have incompatible examples.

Original Message: On the specification, you have and example of an streaming object:

[o][255] [B][4] [D][21.786] [N] [Z] [h][27][131.098412283059e2371293452] [E]

But from the specification of an object, the first item of the pair HAS to be a string. My question is, is this example valid at all?

kxepal commented 12 years ago

Yes, this example is not valid since object keys should be strings.

kxepal commented 12 years ago

Looks like this is the only invalid example on site - quick scan for all objects, arrays and strings hadn't reveal anything else.

[h][27][131.098412283059e2371293452]

^^^ Also is very weird structure. Looks like stripped or something.

adilbaig commented 12 years ago

Its not valid. From json.org

"pair string : value"

kxepal commented 12 years ago

Addition

However, next one looks valid, but not well optimized:

[a][255] [S][3][bob] [I][1024] [T] [F] [S][4][ham!] [E]

S requires 4-byte length while s only 1 byte that fits better there.

ghost commented 10 years ago

Fixed; all these old sections were removed in favor of the updated/rewritten docs under the Type Reference section.

The main spec page just covers high level concerns/motivations/etc. now.