com.alibaba.fastjson.JSONException: syntax error, expect {, actual error, pos 0

v2g6jxz6  于 2022-11-05  发布在  其他
关注(0)|答案(5)|浏览(455)

这是百度统计统计到的错误信息,版本是fasthson-1.1.39
com.alibaba.fastjson.JSONException: syntax error, expect {, actual error, pos 0
at com.alibaba.fastjson.parser.deserializer.JavaBeanDeserializer.deserialze(JavaBeanDeserializer.java:212)
at com.alibaba.fastjson.parser.deserializer.JavaBeanDeserializer.deserialze(JavaBeanDeserializer.java:119)
at com.alibaba.fastjson.parser.DefaultJSONParser.parseObject(DefaultJSONParser.java:514)
at com.alibaba.fastjson.JSON.parseObject(JSON.java:244)
at com.alibaba.fastjson.JSON.parseObject(JSON.java:220)
at com.alibaba.fastjson.JSON.parseObject(JSON.java:179)
at com.alibaba.fastjson.JSON.parseObject(JSON.java:327)
at com.subuy.parse.ShakeStateParser.parseJson(ShakeStateParser.java:16)
at com.subuy.parse.ShakeStateParser.parseJson(ShakeStateParser.java:1)
at com.subuy.net.NetUtil.get(NetUtil.java:385)
at com.subuy.ui.BaseActivity$BaseTask.run(BaseActivity.java:401)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)

json数据为:
{"state":false}

解析的对象文件:
public class ShakeState extends BaseEntity implements Serializable {
private static final long serialVersionUID = 1L;
//摇一摇是否开启判断,state=true 为开启
public boolean state;
public boolean isState() {
return state;
}
public void setState(boolean state) {
this.state = state;
}

}

baseEntity:
public class BaseEntity implements Serializable {
private static final long serialVersionUID = 1L;
public Error error = new Error();
public String response="";

public Error getError() {
    return error;
}

public void setError(Error error) {
    this.error = error;
}

public String getResponse() {
    return response;
}

public void setResponse(String response) {
    this.response = response;
}

public class Error implements Serializable {

public static final long serialVersionUID = 1L;
    public String text;

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

}

}

大神帮忙给瞧瞧,最近这问题包的实在是多啊,但又找不到问题所在

gwbalxhn

gwbalxhn1#

把问题描述清楚。
从异常来看,应该是你提供的数据有问题。

jv2fixgn

jv2fixgn2#

json数据为{“state”:false},这个是Android段解析的数据类型,昨天我查看了一下后台代码,后台是使用state的object类型生成的json数据,我怀疑是这个类型不匹配的问题,但是又不敢肯定,这个错误每天都有好几十次,请大神给瞧瞧 @githublaohu

jecbmhm3

jecbmhm33#

解决了吗,我这边也有类似的问题

deyfvvtc

deyfvvtc4#

解析数据统一使用String类型,然后使用什么类型就转什么类型,问题解决了

nukf8bse

nukf8bse5#

我下载sample-java运行AndroidSampleTest,也是直接报这个错,macaca -v => 2.0.9,有谁能看看吗?

相关问题