Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parse JSON with .NET 2.0

Tags:

json

c#

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.

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

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

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.

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

like image 535
Eels Fan Avatar asked Feb 27 '13 15:02

Eels Fan


4 Answers

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

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

like image 60
Jeff Avatar answered Oct 20 '22 13:10

Jeff


you can, and should, do that with this library http://james.newtonking.com/pages/json-net.aspx

like image 33
Willem D'Haeseleer Avatar answered Oct 20 '22 12:10

Willem D'Haeseleer


I was able to backport Mono's implementation of System.Json to C# 2.0 with a few minor changes.

You'll need 6 files from here or you can simply download my C# 2.0 project from here.

like image 2
Tal Aloni Avatar answered Oct 20 '22 12:10

Tal Aloni


You should be able to use JSON.NET and here is the article describing this

like image 1
Justin Pihony Avatar answered Oct 20 '22 11:10

Justin Pihony