-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
non-global-extensibility #23
Comments
I will probably be trying this out myself for a library I'm writing, so I'll point to some code once I have it. |
Yeah, I've run into this too. I think that Fressian's model might be better for this - you explicitly specify a map of write handlers which are used to serialize, and on the other side you provide a map of read handlers from tags to reader functions. |
ah right, so a map whose keys are classes? |
how should that interact with the builtin functionality? e.g. what happens if I put |
I think you'd want the explicit handlers to override builtin serialization. Fressian also has a nice lookup-by-inheritance feature so you can use superclasses or interfaces to catch all the descendant types. |
okay this sounds cool. incidentally if I end up doing this it will be for https://github.com/gfredericks/webscale |
Alright, I think I got it working here. Some design choices I had to make:
Let me know how this sounds and I can add docs and make a PR. |
(edited previous comment to point to a slightly different commit) |
oh and tests. also I would add tests. |
Released 0.9.0 with support for custom print handlers. |
This is basically the exact same issue as dakrone/cheshire#77 (and affects virtually every other clojure serialization library I've ever used) so I won't elaborate further on the problem statement.
I'm thinking a solution would be another option to the pprint function, which would be a function that accepts a value to be pretty-printed and either returns
{:tag __ :value __}
ornil
, and it would be checked before checking the global protocol (and perhaps before checking built-in functionality as well, though that would probably be a performance concern and I don't know of any use case for it).The text was updated successfully, but these errors were encountered: