Deserialize json object into dynamic object using Json.net

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

    I know this is old post but JsonConvert actually has a different method so it would be

    var product = new { Name = "", Price = 0 };
    var jsonResponse = JsonConvert.DeserializeAnonymousType(json, product);
    

提交回复
热议问题