-
Notifications
You must be signed in to change notification settings - Fork 145
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
ADT Serialization: Recursive types (possible) / Collection of recursive types (not deriving/compiling) #357
Comments
If I understand correctly, your problem was solved in the Discord room. If I’m mistaken, please reopen. |
Hi @fsvehla, the problem is not solved. I tried the solution of concrete structure such as List as advised by @fommil but the problem persist. @plokhotnyuk recognized it as a bug and also opened it in jsoniter (plokhotnyuk/jsoniter-scala#757). He kindly sent me some info about how he solved the problem (in jsoniter) by doing this:
I thought it would be important to support this kind of case as recursive structure. If it is considered a minor issue though it can be closed. |
I think I reproduced the same issue with the following code, but I am getting a null reference exception from java:
|
Shouldn't it be |
So, what does one do with this? |
Disclaimer:
I am new to
zio-json
and new tomagnolia
and couldn't have a convincing answer for my problem in the discord channel so I came here to describe it because it seems to me that there is really some potential problem/enhancement to do.By all means sorry if it is due to my misunderstanding :)
For the moment it is trivial and very comfortable to serialize this kind of recursive structure:
With:
It serialize correctly to:
But we would like to give the King much more subjects with something like (
reignOver
field is now a collection):We get the error(trying
Seq
/List
isn't changing anything):As the derivation is made by
magnolia
I went digging there and there is some example of derivation ofSeq
type classes so it should be possible.The thing is all the instances are in the
JsonEncoder/Decoder/Codec
companion object (seq/iterable
...) and I don't know how it is interacting with magnolia derivation for the moment.I am ready to help and try to solve but I would need some basic direction. Maybe also a more precise diagnostic than what I have done to be sure what is wrong. Thanks for helping.
Cheers!
The text was updated successfully, but these errors were encountered: