-
Notifications
You must be signed in to change notification settings - Fork 1
Ability to pass formatting arguments to JSON backends #77
Description
Feature description
It would be nice if one could natively specify how JSONCollection instances format fields to on JSON dump, e.g. assigning indent, ensure_ascii, separators, etc arguments as found in the json.dump signature
Proposed solution
As a loose implementation, one might unpack the **kwargs passed to JSONCollection.init and isolate those which match the call signature of, e.g. json.dumps, which is only called once AFAIS in the JSON backends implementations. This is the most "brutal", naive way to acheive the desired behavior, and more elegant countersolutions are most welcome given developer input about interactions within synced_collections that I'm unaware of.
Additional context
Such control would be useful for example in Signac Projects, where the one-line job statepoint and document JSON files often become unwieldy and poorly human-readable when inspecting individual jobs. For current projects, I've relied on Project-level hooks to set the indentation on each JSON file write, but it seems like there ought to be an easier way to configure formatting which is natively supported by the stdlib json module (no "crazy" custom formatting being requested here).