[英]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.我正在尝试使用 API 注册用户,并且在成功注册后,我期待像 [234] 这样的用户 ID 作为响应。 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.
但是我收到了提到的错误。注册部分包括 13 个字段,包括编辑文本、复选框和微调器。当我尝试从 API 获取时区值并用值填充它时出现问题。
i just stuck at this conversion and don't know where i am doing wrong.我只是坚持这个转换,不知道我哪里做错了。
enter code here
` enter code here
`
I think your json will be different.我认为你的 json 会有所不同。 you need to fetch json response from server based on objectType but getting string.
您需要根据objectType从服务器获取 json 响应但获取字符串。
You used robopojo plugins for pojo class generate.您使用robopojo插件来生成 pojo 类。
then pass response class into post api.然后将响应类传递到 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;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.