Json is not only useful as a communication tool for APIs, but also may be used as a markup for configuring running programs as initialization.
I encountered the use of references in json schema for the purpose of reuse.
Since json schema is valid json, I had expected the python json library to have the ability to expand references.
$ cat test.json
{
"template":{
"a":"a",
"b":"b",
"pi":3.14
},
"value": { "$ref":"#/template"}
}
python -c "from json import load; fp = open(\"test.json\",\"r\"); print(load(fp))"
{'template': {'a': 'a', 'b': 'b', 'pi': 3.14}, 'value': {'$ref': '#/template'}}
What is the simplest way to expand the references in python, since python dicts cannot point to other parts of themselves (I think)?