News for hackers. Stuff that matters.
Re:Parsing JSON is a Minefield by cptn_brittish on Sunday April 22, 2018 @05:34PM (#16898728)
You use p-lists instead so that {"foo":"bar"} becomes ( :foo "bar")
Re:Parsing JSON is a Minefield by gnud on Sunday April 22, 2018 @06:11PM (#16898906)
Won't you inherit all the encoding trouble this article goes on about? As well as the problems with integer precision? And get a bunch of new ones with special characters in keys...

I'm sure you _could_ specify a nice sexpr format. I'm not sure the specification would be simple though. And just saying "use sexprs" leaves you with all the problems you have when you say "use json".

Re:Parsing JSON is a Minefield by djur on Sunday April 22, 2018 @09:37PM (#16899878)
To put it another way, the biggest problems with JSON aren't with the representation but with the semantics. S-expressions have no inherent semantics beyond those provided by the structure. Take this S-expression:

  ((:foo ("bar" 1))
and this JSON:

  { "foo": [ "bar", 1 ] }
and you'd think they have the same meaning, but they don't. The JSON decodes as "an object with one key, foo, which maps to an array containing the string 'bar' and the number 1." The S-expression decodes as 'the atom :foo is paired with the pair of the atom "bar" and the pair of the atom 1 and the pair of the nil atom." How to interpret the atoms :foo, "bar", and 1, as well as the meaning of their relative positions in the S-expression structure, is the actual hard part.

ETA: I just realized I pretty much repeated what an earlier comment said re: semantics. Sorry for the redundancy.

Re:Parsing JSON is a Minefield by lmm on Monday April 23, 2018 @09:07AM (#16903038)
> How to interpret the atoms :foo, "bar", and 1, as well as the meaning of their relative positions in the S-expression structure, is the actual hard part.

Indeed, which is surely a downside of S-expressions? Anyone reading the JSON will agree that "bar" and 1 are in a linear sequence, and that sequence is somehow labelled "foo". Whereas different readers of the S-expression might not even agree on that much.