Having some issues with JSON using Google Translate API. Not sure where my error is. Would anyone be able to advise?
Here is the response text
{
“data”: {
“translations”: [
{
“translatedText”: “vamos a la tienda”,
“model”: “nmt”
}
]
}
}
Receiving a null reference at line 7
Debug.Log("Received: " + www.downloadHandler.text);
//TranslationResponse translationResponse = JsonConvert.DeserializeObject<TranslationResponse>(www.downloadHandler.text);
translationResponse = JsonConvert.DeserializeObject<TranslationResponse>(www.downloadHandler.text);
Debug.Log(translationResponse);
Debug.Log(translationResponse.TranslationData); // Error here TranslationData is null
OnTranslated(translationResponse.TranslationData.Translations[0].TranslatedText);
public class TranslationResponse
{
public TranslationData TranslationData;
}
public class TranslationData
{
public List<Translation> Translations;
}
public class Translation
{
public string TranslatedText;
public string Model;
}