使用.NET 2.0解析JSON [英] Parse JSON with .NET 2.0

查看:126
本文介绍了使用.NET 2.0解析JSON的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用C#和.NET Framework 2.0版编写的应用程序.不幸的是,我没有选择更新到较新版本的.NET.

I have an app written in C# with version 2.0 of the .NET Framework. Unfortunately, I do NOT have the option of updating to a newer version of .NET.

我的应用正在调用返回一些JSON的网络服务.返回的JSON如下所示:

My app is calling a webservice that returns some JSON. The returned JSON looks something like the following:

{"Status":1, "ID":"12345"}

我需要解析此字符串并获取相应的Status和ID值.如果使用的是.NET Framework的更高版本,则应使用System.Json命名空间.但是,我没有那么奢侈.我不知道如何解析此响应.

I need parse this string and get the respective Status and ID values. If I was using a later version of the .NET framework, I would use the System.Json namespace. However, I do not have that luxury. I have no idea how to parse this response.

有人知道我如何在.NET 2.0中使用C#对此进行解析?

Does anyone know how I can parse this with C# in .NET 2.0?

推荐答案

是的,James Newton-King的 JSON.NET 支持.NET 2.0,并且使用起来非常简单.

Yes, James Newton-King's JSON.NET supports .NET 2.0, and is fairly simple to work with.

我已经使用了很多次,.NET的JavaScriptSerializer只是没有将它剪掉.

I have used it numerous times, where .NET's JavaScriptSerializer just didn't cut it.

这篇关于使用.NET 2.0解析JSON的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆