Add JsonFileUpdater class for simplifying worfking with json files.
file.json:
{
'hello': 'world'
}
f = JsonFileUpdater('file.json')
f['hello'] # 'world'
f['hi'] = 12
file.json after this code:
{
'hello': 'world',
'hi': 12
}
Also i suggest add support for with operator (json.loads -> change keys with [] operator -> json.dumps and write):
with f:
f['hi'] = 12
f['hello'] = 34.2
Also i suggest add support for custom loads() and dumps() functions and for indent (if custom loads() or dumps() are provided, they must support indent argument).
f = JsonFileUpdater('file.json', loads=ujson.loads, dumps=ujson.dumps)
f2 = JsonFileUpdater('file.json', indent=4)
Add
JsonFileUpdater
class for simplifying worfking with json files.file.json
:file.json
after this code:Also i suggest add support for
with
operator (json.loads -> change keys with[]
operator -> json.dumps and write):Also i suggest add support for custom
loads()
anddumps()
functions and for indent (if customloads()
ordumps()
are provided, they must supportindent
argument).