Skip to content
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

Optional types not deserializable? #23

Open
vic-cw opened this issue Apr 16, 2019 · 9 comments
Open

Optional types not deserializable? #23

vic-cw opened this issue Apr 16, 2019 · 9 comments

Comments

@vic-cw
Copy link

vic-cw commented Apr 16, 2019

I might be missing something here, but I am under the impression that RESTClient.factory(SomeResourceWhichReturnsAnOptional) throws an exception.

Caused by: java.lang.NullPointerException
at org.teavm.flavour.json.emit.JsonDeserializerEmitter.emitIdCheck(JsonDeserializerEmitter.java:222)
at org.teavm.flavour.json.emit.JsonDeserializerEmitter.lambda$emitClassDeserializer$20(JsonDeserializerEmitter.java:183)
at org.teavm.metaprogramming.impl.MetaprogrammingImpl.proxy(MetaprogrammingImpl.java:300)
at org.teavm.metaprogramming.impl.MetaprogrammingImpl.proxy(MetaprogrammingImpl.java:238)
at org.teavm.flavour.json.emit.JsonDeserializerEmitter.emitClassDeserializer(JsonDeserializerEmitter.java:172)
at org.teavm.flavour.json.emit.JsonDeserializerEmitter.getClassDeserializer(JsonDeserializerEmitter.java:111)
at org.teavm.flavour.json.JSON.getClassDeserializer(JSON.java:79)

This might be due to the fact that the object mapper has to be configured with the Jdk8 module.

Is that the case?

@vic-cw
Copy link
Author

vic-cw commented Apr 16, 2019

I guess that is the case, since I get the same exception for LocalDate

@ScraM-Team
Copy link
Contributor

ScraM-Team commented Apr 18, 2019

JSON deserialization definitely has some restrictions. Start with primitives, Strings, and Enums (and contained classes containing those types). Be sure to return a value for every field -- nulls tend to cause problems.

The examples are very helpful to see what is possible.

Please post here if you get it working or not.

@ScraM-Team
Copy link
Contributor

Oh, are you using the latest bintray builds or the older 0.1.0 build from maven central?

@vic-cw
Copy link
Author

vic-cw commented Apr 18, 2019

@ScraM-Team thanks for the answer!

Yes I am using 0.1.0 from Maven Central.

I played around, and indeed with different data types things were fine, until I re-introduced either Optional or LocalDate

@ScraM-Team
Copy link
Contributor

The 0.1.0 build is over a year old, you should definitely consider trying the bintray release: https://bintray.com/konsoletyper/teavm/teavm-flavour-dev/0.2.0-dev-52

https://bintray.com/konsoletyper/teavm/teavm-flavour-dev/0.2.0-dev-52

@vic-cw
Copy link
Author

vic-cw commented Apr 20, 2019

Ok thanks, I'll try.

Do you know if support for these types has been added since?

@ScraM-Team
Copy link
Contributor

Sorry, I'm not sure what types were added.

I'm going to start a thread in the forums for Flavour enhancements and feedback on what is trickiest when starting out.

@konsoletyper
Copy link
Owner

Optional types are not supported by Flavour serialization

@vic-cw
Copy link
Author

vic-cw commented Apr 22, 2019

@konsoletyper thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants