简体   繁体   English

我如何解决异常 BEGIN_OBJECT 但 STRING 在第 1 行第 2 列路径 $ 在 android studio 中?

[英]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.

相关问题 Android Studio ArrayList 错误:预期为 BEGIN_ARRAY,但在第 1 行第 2 列路径为 BEGIN_OBJECT - Android Studio ArrayList Error: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $ 我无法获得 JSON 数据“预期为 BEGIN_ARRAY,但在第 1 行第 2 列路径 $ 处为 BEGIN_OBJECT” - I can't get the JSON data "Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $" Gson错误预期为begin_object,但在第1行第1列路径$处为字符串 - Gson error expected begin_object but was string at line 1 column 1 path $ 需要一个字符串,但在第 3 行第 4 列路径 $.SUCCESS 处为 BEGIN_OBJECT - Expected a string but was BEGIN_OBJECT at line 3 column 4 path $.SUCCESS Gson:预期为字符串,但在第 1 行第 3 列路径 $[0] 处为 BEGIN_OBJECT - Gson: Expected a string but was BEGIN_OBJECT at line 1 column 3 path $[0] 预期为 BEGIN_OBJECT,但在第 4 行第 1 列路径 $ - Expected BEGIN_OBJECT but was STRING at line 4 column 1 path $ 预期为BEGIN_OBJECT,但位于第13行第1列的路径$ STRING - Expected BEGIN_OBJECT but was STRING at line 13 column 1 path $ 如何解决此错误 Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $ - How do I solve this error Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $ 预期为BEGIN_OBJECT,但在第1行第6列处为STRING - Expected BEGIN_OBJECT but was STRING at line 1 column 6 “应为 BEGIN_OBJECT 但在第 1 行第 1 列为 STRING” - "Expected BEGIN_OBJECT but was STRING at line 1 column 1"
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM