3 ms·
Why?
by redisman 6y ago
Why?
- wruza 6y agoOne of the uses is mapping values to objects instead of strings, so you don’t have to use ids: 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.