You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Can we make Json deserialization to make use of IParsable types, so for example if a Json property has a string value, but the converting-to type is not a string but is a complex type which implements IParsable<T>, then the de-serialization process should automatically call IParsable.Parse() to try and create an instance of that type.
We may want to restrict it to only allow parsing of value types (structs) ?
Or we may want to have a special attribute on top of IParsable type properties to define whether deserialization can use IParsable.Parse for that specific property or not, something like: [JsonAllowIParsableDeserialization]
if the attribute is applied we can adhere to it, if not we may have a default decision whether yes or not to use IParsable<T>.Parse (which itself might in turn depend if its a value type or object).
Besides above mentioned attribute, we may want to have an general option in the SerializationOptions passed to the Deserialize method.
Is this already the behavior of Json deserialization now?, as far as I have searched its not documented anywhere.
The text was updated successfully, but these errors were encountered:
Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis
See info in area-owners.md if you want to be subscribed.
Issue Details
can we support implementing Json Deserialization to make use of IParsable types, so for example if a json property has a string value, but the converting-to type is not a string but is implementing IParsable, then de-serialization should use IParsable.Parse to try create an instance of that type.
Is this already the behavior of Json deserialization now?, as far as I have searched its not documented anywhere.
Can we make Json deserialization to make use of
IParsable
types, so for example if a Json property has a string value, but the converting-to type is not a string but is a complex type which implementsIParsable<T>
, then the de-serialization process should automatically callIParsable.Parse()
to try and create an instance of that type.We may want to restrict it to only allow parsing of value types (structs) ?
Or we may want to have a special attribute on top of IParsable type properties to define whether deserialization can use IParsable.Parse for that specific property or not, something like:
[JsonAllowIParsableDeserialization]
if the attribute is applied we can adhere to it, if not we may have a default decision whether yes or not to use
IParsable<T>.Parse
(which itself might in turn depend if its a value type or object).Besides above mentioned attribute, we may want to have an general option in the
SerializationOptions
passed to the Deserialize method.Is this already the behavior of Json deserialization now?, as far as I have searched its not documented anywhere.
The text was updated successfully, but these errors were encountered: