musikinformatik / JSONlib

A JSON de- and encoder for SuperCollider
GNU General Public License v2.0
11 stars 0 forks source link

Add custom en-/decoders #3

Closed capital-G closed 1 year ago

capital-G commented 1 year ago

I think it would be neat to allow for custom parsing functions - this would allow e.g. to dump function source code in a JSON file which then could be encoded into a function again during parsing. As this is not part of the official JSON implementation we should not implement it in this lib, but we should allow people to use hooks for this, see e.g. how the python implementation of JSON solves this https://docs.python.org/3/library/json.html#json.JSONEncoder as an inspiration

capital-G commented 1 year ago

Maybe one can provide a function which returns either nil (fallback to default) or. Via #5 we can also represent a null value via Nil instead of nil.