BuddyJoe
BuddyJoe

Reputation: 71171

.NET - JSON Data - Deserialization - Lists & Dictionaries

I need to pull back from a database JSON documents that are not based on a standard object.

Is there a way using .NET to "deserialize" these documents into Lists & Dictionaries of primitive objects (string, int, bool, etc...)

Any library that can do this in both directions?

Upvotes: 5

Views: 1994

Answers (2)

Bob
Bob

Reputation: 7971

In the .NET 3.5 Framework you can use System.Web.Script.Serialization.JavaScriptSerializer. Using the Deserialize method will return an object which you can cast to a Dictionary type or Object[] depending on what's in the JSON string.

Upvotes: 3

Seth Petry-Johnson
Seth Petry-Johnson

Reputation: 12085

The Json.NET library can serialize to and from Dictionary<string, string>, although I don't know if it can deserialize lists of dictionaries. I was trying to figure that out when I came across this question :)

Upvotes: 2

Related Questions