I'm trying to map JSON that looks like
"ids": {
"id": {
"@value":"6763754764235874140"
}
}
And I'd like to map it onto a couple of classes that look like
class Property
{
public Ids Ids { get; set; }
}
class Ids
{
public string Id { get; set; }
}
So basically I want to stuff the value of ids/id/@value
from the JSON document into Ids.Id
in the class architecture. From browsing the documentation, I thought I could use something like
[JsonProperty(ItemConverterType=typeof(IdConverter))]
public string Id { get; set; }
and provide a custom JsonConverter
subclass named IdConverter
. When I do, though, my IdConverter.ReadJson
never gets called. What am I doing wrong?
Looks like the answer was that ItemConverterType
is for converting items in an array. Double-annotating the property with JsonProperty
and JsonConverter
attributes works:
[JsonProperty(PropertyName="id")]
[JsonConverter(typeof(IdConverter))]
public string Id { 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