Example : Currently we can refer name property value in address name property as below
{
person: {
name: "a",
address: {
name: { "$ref":"#/person/name"},
zip:"123"
}
}
}
Is there any way to refer same with relative path like below.
{
person: {
name: "a",
address: {
name: { "$ref":"#/../name"},
zip:"123"
}
}
}
With Above question what I am looking at is an easy way to refer any value in current json where there are complex and multiple hierarchies as given below in first code snippet. For referring “Name” property from sibling I have to mention a complete path right from the root, which can be though to maintain. If there is small change in hierarchy structure the reference will not be valid anymore.
{
"one": {
"two": {
"three": {
"four": {
"five": {
"fiveLevel1": {
"name": "foo"
},
"fiveLevel2": {
"name": {
"$ref": "#/one/two/three/four/five/fiveLevel1/name"
}
}
}
}
}
}
}
}
If we could able to refer the same property as given in second snippet then change in upper hierarchy will not have any impact on reference, There will be only change when there is direct change in the sibling of “FiveLevel1” and “FiveLevel2”
{
"one": {
"two": {
"three": {
"four": {
"five": {
"fiveLevel1": {
"name": "foo"
},
"fiveLevel2": {
"name": {
"$ref": "#../fiveLevel1/name"
}
}
}
}
}
}
}
}