I read from the DB a long json. I want just one attribute of that json.
I have got two options: a. Create an interface for that json and deserialize to that interface.
On .NET 4:
You can do something kind of like what you want minus the need for regex (and you shouldn't use regex for something like this!) by using the dynamic
feature of C# 4.0 described here: http://www.drowningintechnicaldebt.com/ShawnWeisfeld/archive/2010/08/22/using-c-4.0-and-dynamic-to-parse-json.aspx
The only downside is that you can't guarantee what the exact structure of the object is.
The upswing is that instead of accessing members via yourDynamicObject['blah']
, it's the more duck-type-ish yourDynamicObject.blah
On .NET 3.5:
You can use Json.NET: http://json.codeplex.com/