This project has moved. For the latest updates, please go here.

embedded objects?

Mar 25, 2009 at 3:21 PM
How do i serialize this:

"status" : "fail",
"timestamp" : "2009-03-25T14:41:19",
"error" : {
"code" : "4000",
"description" : "not logged in",
"proc" : "INITIALIZE",
"line" : "28"

to get this:

=> "fail"
=> "2009-03-25T14:41:19"
=> "4000"
=> "not logged in"

sorry it it's too wasy. but i'm just at the beginning with dotnet in general.

thx a lot

Apr 3, 2009 at 8:13 PM
First you need to define classes that match this json string in .NET

class Error
    public string code;
    public string description;
    public string proc;
    public string line;
class JsonResponse
    public string status;
    public DateTime timestamp;
    public Error error;

Then you can do JsonConvert.DeserializeObject<JsonResponse>(TheJsonStringYouPosted) to get it deserialized into .Net object.

You should be able to find more information in the documentation.