my C# service is receiving objects from an external service with a "fuzzy" format that looks like:
{
"member": {
"<dynamicProperty>": {
"value":"some_string",
"score": 10
}
}
This property "" can change for every object, I don't have a defined and restricted list for its possible values and of course I can't change this format.
Does anybody know if Json.NET or some other Json .NET serializer, could help me and allow me to define classes like Member
and DynamicProperty
below that I could use for an easy deserialization?
class Member
{
[JsonProperty(PropertyName= "??")] // what should I put here?
public DynamicProperty { get; set; }
}
class DynamicProperty
{
public string value;
public int score;
}
Thanks
You can use a Dictionary<string, object>
class Member
{
public Dictionary<string, object> { get; set; }
}
Or, you can use the JsonExtensionData
Attribute:
class Member
{
[JsonExtensionData]
public Dictionary<string, JToken> { get; set; }
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With