c# - Not able to convert JSON to Java class (call WebApi from Android app) -
im working on school project , im new in android programming have programming experiance in c# , .net.
this code:
    public class proizvodiapi {      public class proizvodivm implements serializable     {         public integer proizvodid;         public string naziv;         public string sifra;         public bigdecimal cijena;         public byte[] slikathumb;         public string jedinicamjere;         public string vrstaproizvoda;     }         public class proizvodilista implements serializable         {             public  list<proizvodivm> proizvodi;         } public static void getallproizvode(final myrunnable<proizvodilista> onsuccess)     {          requestqueue queue = volley.newrequestqueue(myapp.getcontext());         string url = "proizvodi/getproizvodivm";          // request string response provided url.         stringrequest stringrequest = new stringrequest(request.method.get, config.urlapi + url,                 new response.listener<string>()                 {                     @override                     public void onresponse(string response)                     {                         final gson gson = mygson.build();                         final proizvodilista model = gson.fromjson(response, proizvodilista.class);                         onsuccess.run(model);                     }                 }, new response.errorlistener()         {             @override             public void onerrorresponse(volleyerror error)             {                  toast.maketext(myapp.getcontext() , "that didn't work", toast.length_long).show();             }         });         // add request requestqueue.         queue.add(stringrequest);     } } program crashes here:
final proizvodilista model = gson.fromjson(response, proizvodilista.class); is problem deserializing json, if is, shoud change java class , change ?
here c# class in web api:
 public class proizvodi     {         public int proizvodid { get; set; }         public string naziv { get; set; }         public string sifra { get; set; }         public decimal cijena { get; set; }         public byte[] slikathumb { get; set; }          public string jedinicamjere { get; set; }         public string vrstaproizvoda { get; set; }     } 
based on response receiving, jsonarray , not simple jsonobject. deserialize properly.
Comments
Post a Comment