Advertisement
Guest User

Untitled

a guest
Mar 28th, 2020
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.82 KB | None | 0 0
  1. /* PersonajeResponse.cs */
  2. [Serializable]
  3. struct PersonajesResponse {
  4.   public Personaje[] data;
  5. }
  6.  
  7. /* Personaje.cs */
  8. [Serializable]
  9. struct Personaje {
  10.   public Pelo pelo;
  11.   public Ojos ojos;
  12.   public Piel piel;
  13. }
  14.  
  15. /* Pelo.cs */
  16. [Serializable]
  17. struct Pelo {
  18.   public int id;
  19.   public string color;
  20. }
  21.  
  22. /* Ojos.cs */
  23. [Serializable]
  24. struct Ojos {
  25.   public int id;
  26.   public string color;
  27. }
  28.  
  29. /* Piel */
  30. [Serializable]
  31. struct Piel {
  32.   public int id;
  33.   public string color;
  34. }
  35.  
  36. var rawJson = @"{
  37. "data": [{
  38.     "pelo": {
  39.         "id": 1,
  40.         "color": "#ff0",
  41.       },
  42.       "ojos": {
  43.           "id": 1,
  44.           "color": "#000",
  45.       },
  46.       "piel": {
  47.           "id": 1,
  48.           "color": #ffc",
  49.       }
  50.   }]
  51. }";
  52.  
  53. var response = JsonUtility.FromJson<PersonajesResponse>(rawJson);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement