简体   繁体   中英

How can i resolve exception BEGIN_OBJECT but was STRING at line 1 column 2 path $ in android studio?

I am trying to register a user with an API and after successful registration i am expecting a user id like [234] in response. But i am getting the mentioned error.Registration part include 13 fields including edit text,checkbox,and a spinner.the problem is occurred when i am trying to get the timezone value from API and populate it with a value.

i just stuck at this conversion and don't know where i am doing wrong. enter code here `

I think your json will be different. you need to fetch json response from server based on objectType but getting string.

You used robopojo plugins for pojo class generate.

then pass response class into post api.

For example ..

public class ResponseData {

@SerializedName("code")
private Integer code;
@SerializedName("error_message")
private Object errorMessage;
@SerializedName("data")
private List<Datum> data = null;

public Integer getCode() {
    return code;
}

public void setCode(Integer code) {
    this.code = code;
}

public Object getErrorMessage() {
    return errorMessage;
}

public void setErrorMessage(Object errorMessage) {
    this.errorMessage = errorMessage;
}

public List<Datum> getData() {
    return data;
}

public void setData(List<Datum> data) {
    this.data = data;
}

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM