-
Notifications
You must be signed in to change notification settings - Fork 22
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
Enum serialisation and deserialisation is not complementary #33
Comments
I see that this is probably an artefact of using unions to define enums? |
No. This should definite work as you expect - ie the data should "round trip" through the serialisation. Seems like a bug. But... there's something strange about your serialised data:
Did you perhaps use gson to serialise the java object, rather than calling the ADL generated serialisation code? |
Hmmmm....this is in the context of a http response. So I just return the adl generated object and let the http server work out the serialisation by itself. And I believe you're right, the http server does indeed use gson for the serialisation. So you think I should first calle |
Yes. You should be calling These two function:
should be inverses. However, there are (by design) not consistent with the json produced by Gson gson = new GsonBuilder().create(); There's a few reasons for this: gson doesn't support generics easily, it's json isn't necessarily consistent with that produced by libraries for other languages etc. It may be possible to create gson type adapters so that gson can generate ADL compatible json for ADL objects. |
Not an ADL issue... |
I'm not sure if complementary is the word here (invertible maybe?)
If I declare a union such as this:
It reads it in from json as for example
"graphType": "area"
but when it serialises back to json it becomes
It seems like serialisation and deserialisation should be the reverse of each other?
The text was updated successfully, but these errors were encountered: