title: Converting JSON string to array of objects using Gson
body: <p>I'm having issue with conversion of JSON string into array of objects using Gson. I have tried everything I could have find and nothing helped.
  My code is:</p>
  
  <pre><code>   public static ProizvodiViewModel GetProizvode(String tip) {
      String strJson = HttpManager.simpleResponseGet("http://192.168.0.15:21951/api/Proizvodi/SearchProizvodiByVrsta", tip);
  
      Gson gson = new Gson();
      ProizvodiViewModel x = new ProizvodiViewModel();
      x.Proizvodi = new ProizvodViewModel[]{};//tried also with this line commented
  
      try {
          //1st attempt
          //x.Proizvodi = gson.fromJson(strJson, ProizvodViewModel[].class);
  
          //2nd
          //Type type = new TypeToken&lt;List&lt;ProizvodViewModel[]&gt;&gt;() {}.getType();
          //x.Proizvodi = gson.fromJson(strJson, type);
  
          //3rd and so forth (cause many of answers here on SO had almost same idea)
          Type collectionType = new TypeToken&lt;Collection&lt;ProizvodViewModel&gt;&gt;() {}.getType();
          Collection&lt;ProizvodViewModel&gt; enums = gson.fromJson(strJson, collectionType);            
      } catch (Exception e) {
          System.out.println("ERROR IN GSON");
          System.out.println(e.getMessage());
      }
      return x;
  }
  </code></pre>
  
  <p>I had put try catch cause app would break otherwise, and I couldnt read println's.</p>
  
  <p>And my classes:</p>
  
  <pre><code>public class ProizvodViewModel {
     public int Id ;      
     public boolean IsDeleted ;       
     public String Naziv ;
     public float Cijena ;
     public byte[] Slika ;       
     public byte[] SlikaThumb ;       
     public String Status ;
     public int ProizvodDetaljiId ;       
     public int VrstaId ;
  }
  
  public class ProizvodiViewModel
  {
   public ProizvodViewModel[] Proizvodi;
  }
  </code></pre>
  
  <p>I get data in JSON ,as you can see here: <a href="http://pastebin.com/6C7936Uq" rel="nofollow">http://pastebin.com/6C7936Uq</a>
  I am using Android Studio 1.1.0, and api 16.</p>
  
  <p>Edit: Post solved problem. I had my api return json string containing 2 properties of byte arrays, which were converted (I don't know how) into base64 string and I was trying to map them into byte array ,which was causing error. 
  I wrote my api in asp. net application, so if anyone cares to further explain why this happened, please do.</p>