Is it possible to assign references to objects in JSON? I have data that looks like this:
[{ name:"name", Parent:[{ name:"parentName" Parent:[{ .....//and so on }] }] }]
I need to go through it in JavaScript, and also change the personโs name . How can i do this?
name
You can not. You can specify the path to the parent as a string and evaluate it at runtime, but since JSON is just strings, integers, arrays and dictionaries, you cannot use links.
Old question, but some probably new answers like JSON Spec and JSON Reference https://json-spec.readthedocs.io/reference.html
[{ "name": "John", }, { "name" : "Jack", "parent": {"$ref": "#/0"} }, ... ]
or maybe better with JSON Path syntax http://goessner.net/articles/JsonPath/
[{ "name": "John", }, { "name" : "Jack", "parent": {"$ref": "$.[?(@.name=='John')]"} }, ... ]