Various utilities for JSON References (http://tools.ietf.org/html/draft-pbryan-zyp-json-ref-03).
$ref
. Simple merging would mean allowing neighboring properties beside the $ref
and merging the properties of the JSON Reference object and the resolved object. That use case seems simple, of course some ruling for conflicts where both have the same property.
$ref
container for merging, as that's how they did it by mistake in the past. I don't disagree with you that it's semantically "replace the container with the referenced document/fragment" but any reasoning behind why this use case isn't ideal?
test.json
{
"name": "Jeremy",
"$ref": "./jeremy.json"
}
jeremy.json
{
"age": 37
}
resolved.json (merge)
{
"age": 37,
"name": "Jeremy"
}
$ref
with $merge
or $compose
or something else, then you could handle this as well without the ambiguity. Thoughts?
$ref
working. If $ref
was a string, it's a replacement. If it's an object, it's a merge.
$ref
itself doesn't change (replace the container with the resolved value) but you give the author control as to how the resolution happens.