I have a class
public class Order
{
public int Id { get; set; }
public string ShippingMethod { get; set; }
}
and I want to deserialize the JSON data below into a class / object
string json = @"{
'Id': 1,
'ShippingMethod': {
'Code': 'external_DHLExpressWorldwide',
'Description': 'DHL ILS Express Worldwide'
}
}";
My idea is that ShippingMethodin JSON it is an object, but I just want to go to ShippingMethod.Code(in JSON), which will go in ShippingMethodas stringin a Orderclass during deserialization.
how can I achieve this goal by using Json.NET ?
I believe that I can use it using CustomJsonConverter . But I am embarrassed. The example in the docs is for WriteJson, but not for ReadJson.
source
share