Deserialize json object into dynamic object using Json.net

后端 未结 8 1723
感情败类
感情败类 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:55

    Yes you can do it using the JsonConvert.DeserializeObject. To do that, just simple do:

    dynamic jsonResponse = JsonConvert.DeserializeObject(json);
    Console.WriteLine(jsonResponse["message"]);
    

提交回复
热议问题