When trying to update the class properties using JsonConvert.PopulateObject
the JsonPathConverter
is not called and therefore populate is not done.
Sample class:
[JsonConverter(typeof(JsonPathConverter))]
public class SampleClass
{
int id;
[JsonProperty("sample.id")]
public int Id
{
get
{
return id;
}
set
{
id = value;
}
}
}
Call to PopulateObject
:
var sampleClass = new SampleClass() {
Id = 1
};
var str = "{sample:{id:2}}";
JsonConvert.PopulateObject(str, sampleClass, new JsonSerializerSettings());
But the Id
property never gets set to 2.
I've tried JsonSerializerSettings
with converter = new JsonPathConverter()
but it does not work either.
Any idea why it isn't working?