android - Retrofit parsing issue with GSON -


i know question has been asked many time.but not able understand soultion.

i getting below error.

java.lang.illegalstateexception: expected begin_object string @ line 1 column 1 path $ 

below code.

  priceinterface priceinterface = apiclient.getclient().create(priceinterface.class);      map<string, string> params = new hashmap<string, string>();     params.put("date", "today");     params.put("circle", "chandigarh");      call<pricelistbean> call = priceinterface.getmything(params);      call.enqueue(new callback<pricelistbean>() {         @override         public void onresponse(call<pricelistbean> call, response<pricelistbean> response) {             log.e("response is","++++"+response.body().tostring());         }          @override         public void onfailure(call<pricelistbean> call, throwable t) {              log.e("failure message is",""+t.getlocalizedmessage());            // t.getlocalizedmessage();          }     }); 

below json getting server.

 {     "price": [{         "id": 678,         "date_time": "2017-07-25",         "type": "diesel",         "place": "chandigarh",         "price": "55.75"     }, {         "id": 639,         "date_time": "2017-07-25",         "type": "petrol",         "place": "chandigarh",         "price": "64.74"     }],     "errorcode": 0,     "errordesc": "success" } 

i have created pojo this.

public class pricelistbean {  @serializedname("price") @expose private list<price> price = null; @serializedname("errorcode") @expose private integer errorcode; @serializedname("errordesc") @expose private string errordesc;  public list<price> getprice() {     return price; }  public void setprice(list<price> price) {     this.price = price; }  public integer geterrorcode() {     return errorcode; }  public void seterrorcode(integer errorcode) {     this.errorcode = errorcode; }  public string geterrordesc() {     return errordesc; }  public void seterrordesc(string errordesc) {     this.errordesc = errordesc; } 

}

this can done volley or gson trying user retrofit stuck in this. not sure if getting right format json or not


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

.htaccess - ERR_TOO_MANY_REDIRECTS htaccess -