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

Nested optional algaebric datatype cannot be deserialized #3

Closed
blumu opened this issue Aug 11, 2016 · 1 comment
Closed

Nested optional algaebric datatype cannot be deserialized #3

blumu opened this issue Aug 11, 2016 · 1 comment
Labels

Comments

@blumu
Copy link
Contributor

blumu commented Aug 11, 2016

Following code:

type A =
    {
        subField1 : int
        subField2 : int
    }
type B =
    {
        field : A option
    }

let x = { field = Some { subField1 = 1 ; subField2 = 2 } }

let json = Microsoft.FSharpLu.Json.Compact.serialize<B> x
Microsoft.FSharpLu.Json.Compact.deserialize<B> json 

throws the following exception

System.Exception: Nested option types must be serialized as boxed Json objects with attribute 'Some'.
>    at <StartupCode$Microsoft-FSharpLu-Json>.$Compact.parseBox@92(JsonSerializer serializer, Type nestedType, JToken jToken)
   at Microsoft.FSharpLu.Json.CompactUnionJsonConverter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.ResolvePropertyAndCreatorValues(JsonObjectContract contract, JsonProperty containerProperty, JsonReader reader, Type objectType, IDictionary`2& extensionData)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObjectUsingCreatorWithParameters(JsonReader reader, JsonObjectContract contract, JsonProperty containerProperty, ObjectConstructor`1 creator, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
   at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
   at Microsoft.FSharpLu.Json.Compact.deserialize[T](String json)
   at <StartupCode$FSI_0035>.$FSI_0035.main@() in D:\sources\Springfield\source\Script1.fsx:line 161

blumu added a commit that referenced this issue Aug 12, 2016
blumu added a commit that referenced this issue Aug 16, 2016
… can cause ambiguity with the 'Some' attribute.

For instance for discriminated union or records that happen to have a field named 'Some'
blumu added a commit that referenced this issue Aug 16, 2016
… can cause ambiguity with the 'Some' attribute.

For instance for discriminated union or records that happen to have a field named 'Some'
blumu added a commit that referenced this issue Aug 16, 2016
… can cause ambiguity with the 'Some' attribute.

For instance for discriminated union or records that happen to have a field named 'Some'
blumu added a commit that referenced this issue Aug 18, 2016
…lead to ambiguities. (Better and more complete fix for #3)

This ambiguity occurs for instance for discriminated union or record types that happen to have a field named 'Some'
blumu added a commit that referenced this issue Aug 18, 2016
Fix bug #3 and add corresponding test case
@blumu
Copy link
Contributor Author

blumu commented Aug 18, 2016

Fixed by PR #4

@blumu blumu closed this as completed Aug 18, 2016
@blumu blumu added the bug label Aug 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant