Is it possible to deserialize a Json string to an object if Json string has member names with leading/trailing white spaces. I am using Newtonsoft.Json as my serialization library.
For example following is my object type:
public class Sample
{
public ComplexType Default {get; set;}
}
public class ComplexType
{
public IEnumerable<string> Data {get; set;}
}
What I want is if I have below Json string then also it should be deserialized to a valid Sample object. Note there are trailing whitespaces in the name below. Decorating "Default" member with [JsonProperty(PropertyName = "Default ")] in the class is not an option because theoretically I can have any number of leading and/or trailing whitespaces.
{
"Default ":
{
"Data":["data1","data2"]
}
}
Please let me know if there is any out of the box support in Newtonsoft.Json or other approach to solve this. I am looking for a generic solution which can work for any Object structure.
UPDATE: Updated object structure and expected solution.