-
Notifications
You must be signed in to change notification settings - Fork 1
References
To use references, there are three options, local references, external references to a specific value, and external references to a whole file. Refer to the testing directory for more examples. The syntax for each is below.
Simply replaces the value relative to the root of the object. Note that this is relative to the root of the current file, not the current object that reference is contained in.
input.json
{
"a": "b",
"c": { "$ref": "#/a" },
"object": {
"test": "bla",
"another_ref": { "$ref": "#/object/test" }
}
}
Output
{
"a": "b",
"c": "b",
"object": {
"test": "bla",
"another_ref": "bla"
}
}
Note that when referring to external files, it is currently limited to local filesystem references. When parsing them, it will always parse any refs in those files recursively before merging the result into the main file.
This uses the same syntax for object selection as above.
input.json
{
"foo": { "$ref": "./bar.json#/baz" },
"far": "test"
}
bar.json
{
"baz": "bar",
"c": "d"
}
Output
{
"foo": "bar",
"far": "test"
}
To include an entire file, simply reference it by path without any query on the end.
input.json
{
"foo": { "$ref": "./bar.json" },
"far": "test"
}
bar.json
{
"baz": "bar",
"c": "d"
}
Output
{
"foo": {
"baz": "bar",
"c": "d"
},
"far": "test"
}