tags:

views:

62

answers:

2

I'm currently using jqGrid to display data. Part of jqGrid's interface will give you search options, posting back the search details in a JSON string, for example:

{"groupOp":"AND","rules":[{"field":"PersonID","op":"eq","data":"123"},{"field":"LastName","op":"eq","data":"Smith"}]}

(meaning i'm searching for personID = 123, and LastName = 'Smith')

so what i'm hoping to do is somehow convert that back into something i can use server-side.

Does anyone have a solution for this that may convert it back into an object of some kind? My current solution would be to convert into xml, parse with linq and create instances of my own 'search' class with a 'rules' collection.

+1  A: 

Json.NET is a very rich JSON parser for .NET (I know, Captain Obvious huh...)

As far as I know, using the built-in JsonDataContractSerializer won't do what you're looking for because it requires a known type that provides the data contract. Without an existing type to deserialize to, it can't just produce a dynamic object.

Josh Einstein
+1  A: 

You can use JavaScriptSerializer to serialize/deserialize between json and your Search class.

ob