TheDude
TheDude

Reputation: 3952

Parsing Json String

Is there a native library that would allow me to parse a Json formatted string? Say, for example, I had the string:

string inp = "{ \"title\": \"My Title\" }";

Is there a class where I can construct an object using that Json formatted string and find the value for title?

Edit: My app is a console application.

Upvotes: 3

Views: 2303

Answers (4)

Mike Parkhill
Mike Parkhill

Reputation: 5551

You should check out Json.Net http://json.codeplex.com/ It has all sorts of great tools for supporting Json in. Net

Upvotes: 1

Erre Efe
Erre Efe

Reputation: 15557

Not a native but a powerful one: Json.NET

  • Flexible JSON serializer for converting between .NET objects and JSON
  • LINQ to JSON for manually reading and writing JSON
  • High performance, faster than .NET's built-in JSON serializers
  • Write indented, easy to read JSON
  • Convert JSON to and from XML
  • Supports .NET 2, .NET 3.5, .NET 4, Silverlight, Windows Phone and Windows 8.

Upvotes: 3

Brad Christie
Brad Christie

Reputation: 101594

Depending on the type of project, JavaScriptSerializer may be available. Also allows you to create parsers that can populate custom objects.

Upvotes: 1

Eric J.
Eric J.

Reputation: 150108

You can use the DataContractJsonSerializer to deserialize a Json formatted string into an object

http://msdn.microsoft.com/en-us/library/bb410770.aspx

For better performance, if you're willing to install a NuGet package,

http://json.codeplex.com/

is quite popular.

Both alternatives work for a console application.

Upvotes: 5

Related Questions