Deserialize json object into dynamic object using Json.net

后端 未结 8 1718
感情败类
感情败类 2020-11-21 22:07

Is it possible to return a dynamic object from a json deserialization using json.net? I would like to do something like this:

dynamic jsonResponse = JsonConv         


        
8条回答
  •  甜味超标
    2020-11-21 22:56

    If you just deserialize to dynamic you will get a JObject back. You can get what you want by using an ExpandoObject.

    var converter = new ExpandoObjectConverter();    
    dynamic message = JsonConvert.DeserializeObject(jsonString, converter);
    

提交回复
热议问题