Standard way of referencing an object by identity (for, eg, circular references)?

前端 未结 4 1206
暗喜
暗喜 2020-11-29 05:49

Is there a standard way of referencing objects by identity in JSON? For example, so that graphs and other data structures with lots of (possibly circular) references can be

4条回答
  •  时光说笑
    2020-11-29 06:35

    There is no canonical way to achieve that. JSON does not have a native support for references, so you have to invent your own scheme for unique identifiers which will act as pointers. If you really want to make it generic you could use the object identifiers provided by your programming language (eg. object_id in Ruby or id(obj) in Python).

提交回复
热议问题