3 ms·
JSON is nearly sexps already. It's about as lispy you can get without being Lisp. The curly braces could be changed to parentheses and it would be rather trivi
by yason 15y ago
JSON is nearly sexps already.
It's about as lispy you can get without being Lisp. The curly braces could be changed to parentheses and it would be rather trivial to write a Lisp macro to parse JSON into a nested set of associative arrays or hash maps.
In fact, if you just remove the JS ':' member notation, you can shove most of JSON into a Clojure repl already, since Clojure supports the convenient {} notation for maps.
There's no reason to make JSON look precisely like Lisp. Given that many people seem to be allergic to Lisp-style nested parentheses once they've been educated that it's Lisp, JSON offers the flexibility of constructing arbitrary sexp trees without people ever noticing they're almost generating and parsing Lisp.
When writing Lisp, it's of course sensible to use sexps instead of JSON for internal marshalling.
- itmag 15y agoHow can control structures be implemented with JSON, though?
- lloeki 15y agoThe same as in LISP. Code being data and data being code, an 'if' is a function that merely returns/evaluates either second or third argument based on first argument evaluation. Reminds me of this tiny LISP: http://www.brool.com/index.php/the-tiniest-lisp-in-python http://www.brool.com/index.php/the-tiniest-lisp-in-python
- arethuza 15y agoLispish: ( if ( > a b ) 'foo 'bar ) JSON: [[ "if" [ ">" a b ] "foo" "bar" ] If you are writing code then I'd go for the Lisp approach, for general purpose data then these days I'd go with JSON.
- joesb 15y agoAnd how can that S-EXP control structure be usable in all other scripting language beside Lisp? If you can answer this question then you have already answered your own question. But if your answer is "I don't have to because I use Lisp and I don't use other languages" then you miss the point of JSON.
- deleted 15y ago[deleted]