Add JSON load()/dump() convenience like Python
Python has really handy functions for loading/dumping JSON to a file, and GJS could do a little better in this area. I doubt anyone would be opposed to a few overrides and it's trivial to implement, but some discussion is always good if we're adding new APIs/overrides:
- should we emulate Gio/GTask closely with separate sync/async functions?
- use a boolean arg with a sane default, returning a Promise if appropriate?
- or "pre-promisify"/follow @llzes' work? (Your input would be great here, since this type of DX is something you've approached already)
JSON.stringify()args through makes sense (eg.
replacerfunc), but maybe we should also support (un)serializing things like GVariants and GIcons? Maybe adding
toJSON()to their prototypes?
I've been using simple overrides myself for some time along these lines:
// snipped out for easy scrolling