Why does JSON only allow a string
to be a key of a pair
? Why not other types such as null
, number
, bool
, object
, array
? Considering JSON is tightly related with JavaScript, could I conclude the reason from JavaScript specification (ECMA-262)? I'm totally a newbie to JavaScript, could you help me to point it out.
Maybe it's not wise using null
and bool
, but I think number
and object
are OK. Just like Hashtable
in C# which allows me to store almost anything as a key. I'd like to use generic types for key not only string
in some situation; value in JSON is generic, why not key.
Thanks!