Deserialize jSON Google AJAX Translation API
- by Chris Porter
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.