by leiferik · 4y ago · 0 comments
* Can represent sets `#{1 2 3 4 "foo" "bar" true false}` (JSON only supports arrays)
* Maps/sets can contain arbitrary EDN as keys/values. `{[1 2] "foo", 5 :a, "5" :b, true -1, false 5}` or `#{[1 2] #{3 4} (5 6)}` (JSON only supports string keys on "objects")
* Supports clojure types like keywords (`:foo`, `:bar/baz`) and symbols (`foo`, `bar/baz`), and can be extended to support other values as well
2. JS has Map/Set which allow other composite types as keys and can be converted to objects for JSON serialization then deserialize back to Map/Set.
[
["key", "value"],
["otherKey", "otherValue"]
]
or [
{"key": "key", "value": "value"},
{"key": "otherKey", "value":"otherValue"}
]
or something else? And how can I distinguish between values which just happen to look like maps but are actually not maps? And what if the service I'm talking to does it differently? What if I'm comparing or sorting two JSON values, don't I have to modify the equality/hashcode/ordering logic now to interpret [
["key", "value"],
["otherKey", "otherValue"]
]
and [
["otherKey", "otherValue"],
["key", "value"]
]
as being equal and implement a new hashcode/ordering which treats them as equal?Quite a lot easier when this is just native to the format.