-
Notifications
You must be signed in to change notification settings - Fork 47
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
Custom encoding of variants #27
Comments
No, this is not possible. The problem with adding this as a feature is that it is not flexible; there is no single format JSON APIs use for serializing sum types. |
Ok, no problems. I just used |
I'm actually open to ideas in regards to this, I just don't know how/if it can be implemented without bloating the interface terribly. |
Mmmh at least allowing |
By the way, generally speaking, with ppx is it possible to enforce that attributes (such as ``[@name "name"]`) have to be used by a ppx module ? |
https://github.com/whitequark/ppx_deriving_yojson#options And to the second question, no. There's been discussion on schemas on mantis but those are vaporware. |
Ohh thanks a lot ! |
I have to deal with similar json schemes, I usually handle this the following way:
It is not very easy to figure out a solution that will work with all popular APIs because they all have their pecularities. Maybe an acceptable solution would be the ability to specify for a specific field a family of deserialisers that would have to be tried sequentially deserailse the json structure. I am not sure how this feature should be combined with variants – should they return |
Hi,
I've the following json format to parse:
I can have either:
or:
And what I would like to do is something like that:
Is it already possible to do something like that or otherwise, is it possible to add such a feature ?
The text was updated successfully, but these errors were encountered: