I have this code:
var jsonResponse = response.Content.ReadAsStringAsync().Result;
List<TranslationResult> a = JsonConvert.DeserializeObject< List<TranslationResult>>(jsonResponse);
var t0 = (a[0] != null) ? a[0] : null;
var t1 = (t0 != null) ? t0.Translations[0] : null;
var t2 = (t1 != null) ? t1.DisplayTarget : null;
var p2 = (t1 != null) ? t1.PosTag : null;
public class TranslationResult
{
public string DisplaySource { get; set; }
public Translation[] Translations { get; set; }
}
public class Translation
{
public string DisplayTarget { get; set; }
public string PosTag { get; set; }
}
The code I am using with all the null tests looks messy and I would like to clean this up. Can anyone suggest a way that I can do this or perhaps suggest a way using LINQ if that's possible. Note that I only need the DisplayTarget and PosTag details.