Are references possible in JSON? Are references possible in JSON? json json

Are references possible in JSON?


Old question but some possibly new answers like JSON Spec and JSON Reference https://json-spec.readthedocs.io/reference.html

[{  "name": "John", }, {  "name" : "Jack",  "parent": {"$ref": "#/0"} }, ...]

or possibly better with JSON Path syntax http://goessner.net/articles/JsonPath/

[{  "name": "John", }, {  "name" : "Jack",  "parent": {"$ref": "$.[?(@.name=='John')]"} }, ...]


You can't. You can specify the path to the parent as a string and evaluate that at runtime, but as JSON is just strings, integers, arrays, and dictionaries, you can't use references.