Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. {
  2. "data": {
  3. "countries": [
  4. {
  5. "translatedName": "Ascension Island",
  6. "translations": [
  7. {
  8. "languageCode": "bg-BG",
  9. "translatedName": "Остров Възнесение"
  10. },
  11. {
  12. "languageCode": "cs-CZ",
  13. "translatedName": "Ascension"
  14. }
  15. ]
  16. }
  17. }
  18.  
  19. class Country
  20. {
  21. public string TranslatedName { get; set; }
  22.  
  23. public List<Dictionary<string, string>> Translations { get; set;
  24. }
  25.  
  26. public T Parse<T>(string fieldName, string json)
  27. {
  28.  
  29. }
  30.  
  31. public T Parse<T>(string fieldName, string json)
  32. {
  33. return JObject.Parse(json)[fieldName].ToObject<T>();
  34. }
  35.  
  36. var countries = Parse<List<Country>>("countries", ....); //it fails due to the fact it does not know how to convert translations to dictionary
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement