I'm trying to take some JSON containing references and resolve them. I'm using the jsonref library to do it. I have reduced my problem to these two cases:
import jsonref
print(jsonref.JsonRef.replace_refs(jsonref.loads('''
{
"foo": {
"$ref": "#/def/bar"
},
"def": {
"bar": "baz"
}
}
''')))
# works: {'foo': 'baz', 'def': {'bar': 'baz'}}
print(jsonref.JsonRef.replace_refs(jsonref.loads('''
{
"foo": {
"$ref": "#/def/obj"
},
"def": {
"obj": {
"bar": "baz"
}
}
}
''')))
# expected: {'foo': { 'bar': 'baz'}, 'def': {'bar': 'baz'}}
# actual: AttributeError: 'generator' object has no attribute 'get'
The first one works, but the second one throws an error. Why?