←back to thread

Fixing JSON

(www.tbray.org)
139 points robin_reala | 1 comments | | HN request time: 0.211s | source
Show context
lhopki01 ◴[] No.12327755[source]
Just use yaml?
replies(3): >>12327787 #>>12328256 #>>12328267 #
wtetzner ◴[] No.12327787[source]
Or if you still want something easy to parse, s-expressions.
replies(1): >>12327927 #
omginternets ◴[] No.12327927[source]
Could you please elaborate? I'm vaguely familiar with S-expressions from my cursory inquiry into lisp (planning to take the plunge in November), but I don't see how they can be applied in this context.
replies(1): >>12327996 #
nv-vn ◴[] No.12327996[source]
S-expresions are really just a way of representing a tree of data (in Lisp code, the S-expression literally represents the abstract syntax tree that is used for the code).

Take the JSON example:

    {
      "IDs": [116, 943, 234, 38793],
      "Settings": { "Aperture": 2.8, "Shutter speed": "1/250" }
    }
You could rewrite this as an S-expression as:

    ((IDs (116 943 234 3879))
     (Settings
       (Aperture 2.8)
       ("Shutter Speed" "1/250")))
replies(1): >>12328468 #
1. omginternets ◴[] No.12328468[source]
Thanks! I figured it would be simple, and indeed it was :)