I have a class
public class Order
{
   public int Id { get; set; }
   public string ShippingMethod { get; set; }
}
and I want to deserialize a JSON data below into the above class/object
string json = @"{
  'Id': 1,
  'ShippingMethod': {
     'Code': 'external_DHLExpressWorldwide',
     'Description': 'DHL ILS Express Worldwide'
  }
}";
My idea is that ShippingMethod in JSON is a object, but I just want to get to ShippingMethod.Code (in JSON) that will pass into ShippingMethod as string in Order class during deserialization.
how can I accomplish that goal using Json.NET?
I believe I can accomlish it using CustomJsonConverter. But I get confused. The example in the docs just for WriteJson, but not ReadJson.



CodeandDescriptionare insideShippingMethod? How are serialized?ShippingMethodis object in the json and string in C# class. How you can map this. You have to change the code as below.