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
Unable to serialize generics in Scala #100
Comments
Unfortunately, thats currently expected behavior. Ideally Scala version will get some kind of compilation support... but community should help out with that. |
I see. I guess at the time being, generics are only supported in Java version ? |
Yes |
So I tried recoding it in Java but it still didn't work. Finally I copied and ran GenericTest but all tests failed. I was using dsl-json-java8, version: 1.8.3 (version 1.8.4 was not yet available at Maven). This is one result I get from
|
If you write your example as a test in GenericTest does it work then? If not, can you make a PR? I suspect that you need to initialize library via new |
I copied the file without changing anything. DslJson is initialialized like this
And I tried cloning the project. It failed to build with the same reason as when I did it with my own test. Basically |
dsl-json 1.8.4 is not released, but you should be able to build it locally by going to root project and running
That should build the entire project including the external-models. |
Still failed with error
though test-compile works. |
Would be very keen for generics support in Scala. |
Yes, it would be nice to resolve such minor TODOs: https://github.com/ngs-doo/dsl-json/blob/master/scala/src/main/scala/com/dslplatform/json/runtime/ScalaClassAnalyzer.scala#L20 I don't have much time ATM, but I suspect it would not be complicated to add that support for reflection. |
There is now basic support for generics in Scala: https://github.com/ngs-doo/dsl-json/blob/master/scala/src/test/scala/com/dslplatform/json/GenericsTest.scala Will be included in 1.8.5 |
v1.8.5 released |
I have been unable to serialize a generic class using GenericTest as reference. I have below a very simple class in Scala. To imitate the Java test code I don't use Option or case class.
res
always returns false signifying failed serialization. Perhaps you could help point out the problem ? Thank you.The text was updated successfully, but these errors were encountered: