解析JSON字符串JSON对象在C#.NET字符串、对象、JSON、NET

2023-09-02 21:12:05 作者:抹灭我想要挽留的念头、

我有一个JSON字符串返回在.NET我SOAP的Web服务。它如下所示:

I have a JSON String returned by my SOAP web service in .NET. It is as follows:

{checkrecord:[{rollno:ABC2,百分比:参加40:错过了12:34}],表1:[]}

{"checkrecord":[{"rollno":"abc2","percentage":40,"attended":12,"missed":34}],"Table1":[]}

现在我想分析该字符串的JSON对象。我也看了这,他们已经用这种线code:

Now I want to parse this string to a JSON Object. I also read this where they have used this line of code:

JObject jsonObj = JObject.Parse(JSON);

JObject jsonObj = JObject.Parse(json);

所以我可以做同样的用我的字符串名称替换JSON。另外,我需要引用任何其他的dll除了NewtonSoft.dll?

So can I do the same by replacing "json" with my string name. Also do I need to reference any other dll except the NewtonSoft.dll ?

顺便说一句,下面是完整的web服务 code

BTW, Here is the full webservice code

推荐答案

使用新JavaScriptSerializer.Deserialize<对象>(jsonString)

您需要System.Web.Extensions程序的DLL相同,导入下列命名空间。

You need System.Web.Extensions dll for the same and import the following namespace.

命名空间:System.Web.Script.Serialization

Namespace: System.Web.Script.Serialization

有关更多信息 MSDN

for more info MSDN