Deserialize jSON Google AJAX Translation API

Posted by Chris Porter on Stack Overflow See other posts from Stack Overflow or by Chris Porter
Published on 2008-10-05T14:59:20Z Indexed on 2010/03/16 16:11 UTC
Read the original article Hit count: 353

Filed under:
|
|
|

I've got the JSON coming back like this:

{"responseData": [{"responseData":{"translatedText":"elefante"},"responseDetails":null,"responseStatus":200},{"responseData":{"translatedText":"Burro"},"responseDetails":null,"responseStatus":200}], "responseDetails": null, "responseStatus": 200}

And I need to parse it into a ResponseData object I have set-up:

    public class ResponseData
    {
        public string translatedText = string.Empty;

        public object responseDetails = null;

        public HttpStatusCode responseStatus = HttpStatusCode.OK;
        public List<ResponseData> responseData { get; set; }
    }

I Deserialize it like this:

JavaScriptSerializer serializer = new JavaScriptSerializer();
ResponseData translation = 
                    serializer.Deserialize<ResponseData>(responseJson);

But no matter what the translated text is always empty.

© Stack Overflow or respective owner

Related posts about AJAX

Related posts about c#