You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
It's related to the discussion in #1861, Say I have this ADT:
data X = y(int a) | z(str b);
I cannot serialize that to json and back, as it looses the constructor name (there is not reasonable place for it).
Describe the solution you'd like
I want to propose we extend the heuristic, to gather the names of the parameters found in json, and based on that, pick the constructor that has those parameters.
We would have to (in the JsonValueReader) calculate the union of all field names of the alternatives for the ADT, and buildup that positional & kw parameters based on that, and only at the end build the positional & kw params maps that goes into the constructor.
Describe alternatives you've considered
Update the documentation to say that an arbitrary constructor will be chose, and you have no control over it. The current documentation is ambiguous, and seems to suggest the names of parameters are considered.
Additional context
Yes, this is not fool proof, but it will make the json deserialization work in more cases for the confused end user.
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
It's related to the discussion in #1861, Say I have this ADT:
I cannot serialize that to json and back, as it looses the constructor name (there is not reasonable place for it).
Describe the solution you'd like
I want to propose we extend the heuristic, to gather the names of the parameters found in json, and based on that, pick the constructor that has those parameters.
We would have to (in the
JsonValueReader
) calculate the union of all field names of the alternatives for the ADT, and buildup that positional & kw parameters based on that, and only at the end build the positional & kw params maps that goes into the constructor.Describe alternatives you've considered
Update the documentation to say that an arbitrary constructor will be chose, and you have no control over it. The current documentation is ambiguous, and seems to suggest the names of parameters are considered.
Additional context
Yes, this is not fool proof, but it will make the json deserialization work in more cases for the confused end user.
The text was updated successfully, but these errors were encountered: