我有 JSON 像这样回来:
{
"responseData": [{
"responseData": {
"translatedText": "elefante"
},
"responseDetails": null,
"responseStatus": 200
}, {
"responseData": {
"translatedText": "Burro"
},
"responseDetails": null,
"responseStatus": 200
}],
"responseDetails": null,
"responseStatus": 200
}
我需要将其解析为我设置的 ResponseData 对象:
public class ResponseData
{
public string translatedText = string.Empty;
public object responseDetails = null;
public HttpStatusCode responseStatus = HttpStatusCode.OK;
public List <ResponseData> responseData { get;set; }
}
我像这样反序列化它:
JavaScriptSerializer serializer = new JavaScriptSerializer();
ResponseData translation =
serializer.Deserialize<ResponseData>(responseJson);
但无论什么翻译的文本总是空的。