Convert JSON String To C# Object

前端 未结 14 2140
感情败类
感情败类 2020-11-22 14:27

Trying to convert a JSON string into an object in C#. Using a really simple test case:

JavaScriptSerializer json_serializer = new JavaScriptSerializer();
obj         


        
14条回答
  •  时光取名叫无心
    2020-11-22 14:47

    Or, you can use the Newtownsoft.Json library as follows:

    using Newtonsoft.Json;
    ...
    var result = JsonConvert.DeserializeObject(json);
    

    Where T is your object type that matches your JSON string.

提交回复
热议问题