[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ProgSoc] XML languages



John Elliot wrote:
Does this mean I can keep my null-embedded string, my octal float and my regex? :)
Hang on a sec... *squints*

Well you proved that I can't hand-parse that on the first attempt in my head... OK, I fixed the thing. :)
Null-embedded string is OK if the "null" is spelled "\u0000".

I'm not sure about literal null bytes in the input. The spec says no "control characters" are allowed in strings, but doesn't say what a control character is. In any case, simplejson accepts literal nulls in the obvious way.
You can't have octals or regexes.

So you end up with this:
{
  "haha": "yeah, sure",
  "for":3,
  "you":"", "to": [ "parse",
"this", "I"
, "to", "parse", "this\n\"" ]
}

... which even I can parse!

>>> simplejson.load(file('test.txt'))
{u'to': [u'parse', u'this', u'I', u'to', u'parse', u'this\n"'], u'you': u'', u'haha': u'yeah, sure', u'for': 3}
I think this actually makes your point better: JSON is a really simple 
and well-specified language. Simplejson is 1034 lines total, and 371 of 
those are the encoder.
p.s. I didn't realise that double-quotes were required around otherwise syntactically valid identifiers...
I love the way that site uses railroad diagrams! :) Brings back memories.

- N

-
You are subscribed to the progsoc mailing list. To unsubscribe, send a
message containing "unsubscribe" to progsoc-request@xxxxxxxxxxxxxxxxxxx
If you are having trouble, ask owner-progsoc@xxxxxxxxxxxxxxxxxx for help.