-
Notifications
You must be signed in to change notification settings - Fork 304
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
Serializing int64 inside discriminated unions generates irreversable JSON representation #1411
Comments
Hi @Zaid-Ajaj! Thanks a lot for the report and sorry for replying late. At the end we're deprecating JSON serialization in Fable 2, and instead we're adding auto-decoders to Thoth so we'll have to solve this issue there (if it's still happening). BTW, the good news is Reflection is already implemented in Fable 2, so Fable.Remoting will likely work with the alpha release 😄 |
Thanks for the reply, maybe I missed something so I have a couple of questions
Should I assume that
Were these the code-generated specialized functions to serialize/deserialize objects?
Awesome, I will soon be running the tests against Fable 2 to see how things are going, though if Lastly, if is it not a big issue, can it still be fixed to the Fable 1.3.x branch? |
@Zaid-Ajaj Indeed But we will provide equivalent via For example, if you have a property : |
@MangelMaxime I took a closer look, very interesting way for deserialization, I wonder if it can handle the exhaustive test suite of Fable.Remoting, I will try it soon and otherwise I will be swarming you with issues 😂 😜 |
Thank you :) I think it will not pass the test suite yet. I need to had more primitive type like Dates for example :) |
@alfonsogarciacaro This issue looks exactly like #1374 where the value (of type int64) inside the union is not It has something to do with this block of code and the import { isLong } from './Long'
function deflateValue(v: any) {
if (isDate(v)) {
return deflateDate(v);
}
if (isLong(v)) {
return v.toJSON();
}
return v;
} |
Description
Serializing int64 inside discriminated unions generates incompatible JSON, in other words, the generated JSON cannot be deserialized back to original type.
After tracking down the issue at Fable.Remoting, I narrowed it down to the following code that doesn't work:
You will get the error:
The Fable
JsonConverter
on the server is also unable to deserialize the date{"low":20,"high":0,"unsigned":false}
into a properint64
and throws this exception:where the
StartObject
indicates that the deserializer encountered an object literal where it was expecting int64Related information
dotnet fable --version
): 1.3.17 && replThe text was updated successfully, but these errors were encountered: