Deserializing just a single node of a JSON response

后端 未结 2 792
慢半拍i
慢半拍i 2021-01-25 15:01

I have a json response like

{
  \"appStatus\":{
    \"status\":true
  },
  \"lastSyncDate\":\"06-07-2013 13.54.27\",
  \"configResponse\":{
    \"status\":{
            


        
2条回答
  •  北荒
    北荒 (楼主)
    2021-01-25 15:36

    You can parse JSON string into JObject, get sub-object "configResponse", then deserialize it into ConfigResponse. It's one line of code:

    JObject.Parse("{...}")["configResponse"].ToObject()
    

    If you need a custom serializer to set deserialization options, you can pass it to ToObject() method.

提交回复
热议问题