{ [1, 2]: "a", [3, 4]: "b" }
{ [1, 2]: "a", [3, 4]: "b" }
'Welcome to Node.js v15.7.0.
Type ".help" for more information.
> { [1, 2]: "a" }
({ [1, 2]: "a" })
^
Uncaught SyntaxError: Unexpected token ','
Thar' be dragons! https://stackoverflow.com/questions/32660188/using-array-obj...However, it's equally true that a better language and object notation would support non-string scalar keys.
However, I don't think it is useful to prod JSON (or a variant) to go in this direction.
People are more interested in JSON derivatives like JSON5 or Ion than more complex languages like Dhall in my experience.
Dhall is new to me. Would you tell me more about other configuration languages you seen? I often use TOML myself.
If it's a map I'm a bit more unsure how you'd check to find the object (quickly). You're basically getting into the how to store a struct/class as a map key. Either way its a bit more involved than just having json parser return an immutable array and map, and the more I think about it the more edges cases there are.
I'm here to tell you that `Object.freeze()` works just fine on arrays.
I guess you could have this json+ convert into some custom javascript class that allows arrays/objects as map keys rather than the normal javascript object that only accepts strings as map keys.
Sure - why not? JSON doesn't have to map directly to JavaScript objects.
ob = {...}
somemap[ob] = value
// vs
somemap[ob.id] = value
In languages which allow weak keys in such maps, a garbage collector may even reclaim whole key-value pairs once ob falls out of existence. But to my opinion, in json it is barely useful for a number of reasons. It is more programming technique than data transfer format, and these features (and reference loops) should be encoded at a higher level than json.