Open fportantier opened 8 years ago
Ok... my bad... searching on the internet:
with open('db.json', 'r') as file: data = ujson.loads(file.read()) db = DB(**data)
So simple!!! Sorry about the question,
only let me suggest that you put an example similar to the above on the docs, because it's very useful and I think that isn't present.
Regards and congrats for your awesome work!
Hi,
Nice to hear that, I'm glad it's useful for you :)
Anyway about reading json from file - well, json module is one great tool from python core - it's really well documented (https://docs.python.org/3/library/json.html) and, since it's core, I didn't want to put this into jsonmodels docs, since I wouldn't make it better than what's done already.
But in the end, I'll consider putting at least url to json docs. Thanks for feedback :)
Hi !
I'm very impressed with jsonmodels, it's awesome!
I only don't know how I can save the data to json an, later, load it into the model, like this:
with open('data.json', 'r') as file: data = ujson.loads(file.read()) db = DB(load=data)