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
Fable vnext json de/serialisation issues and matching unions #473
Comments
Thanks for the sample, @7sharp9! I tried to run your code in F# interactive (changing let ents =
[Type {name= "testType"; ``type`` = TypeClassification.Type; members = testMembers}] With this change I went back to Fable serialization, compiled to JS and it worked. Could you please try that too? |
Hmm, yeah that works in the sample above, in the real code that fails there is no unbox though... |
Is this what you used in to serialise? let settings = JsonSerializerSettings(Converters = [|Fable.JsonConverter()|])
JsonConvert.SerializeObject(v, settings) |
As the code listed above is serializing and deserializing, it works either if you use {
"name": "test",
"entities": [
{
"Case": "Type",
"Fields": [
{
"name": "testType",
"type": 0,
"members": [
{
"Item1": "test",
"Item2": 0,
"Item3": "int -> unit"
}
]
}
]
}
]
} And this is with Fable.JsonConverter: {
"name": "test",
"entities": [
{
"Type": {
"name": "testType",
"type": 0,
"members": [
[
"test",
0,
"int -> unit"
]
]
}
}
]
} You mention the real code has not unbox and still fails. Could you please check that the proper type is passed to |
Essentially I think the serialisation was a red herring, the issue I was having was in a match block where the incorrect json parameters were being accessed. The js code produced was this:
The interesting section was this:
Which should of been like this:
|
As we talked, the produced JS code is fine because Fable always represents unions at runtime as |
Description
Fable vnext de/serialisation issues
Repro steps
Please provide the steps required to reproduce the problem
The following code fails to deserialise:
I have tried using
Fable.JsonConverter
to do the serialisation but that fails with a different error.Expected behavior
deserialisation occurs successfully
Actual behavior
Fails with:
Known workarounds
Manually edit js
Related information
The text was updated successfully, but these errors were encountered: