admin管理员组文章数量:1794759
JSONObject.parseObject syntax error,expect START WITH { OR [,but actually START WITH error
JSONObject.parseObject syntax error,expect START WITH { OR [,but actually START WITH error 解析JSON出现异常(JSON返回结果)
请求的url格式错误: 正确的:https://服务的IP:端口 /接口名称 ?参数列表 错误的:https://服务的IP:端口 ?参数列表
排查方法:可以将接口请求的返回结果打印出来,如果不是json的字符串,在做转换的时候,会报该错误。
代码语言:javascript代码运行次数:0运行复制ResponseData responseData = JSONObject.parseObject(responseStr,ResponseData.class);
public class ResponseData<T> {
private static final long serialVersionUID = 6898451165550538312L;
@AutoDocProperty("返回代码")
private String resCode;
@AutoDocProperty("返回消息")
private String resMsg;
@AutoDocProperty("返回实体")
private T data;
}
//如果对接收到的json串转换为对象,需要将接收类具体化,而不是T泛型的方式。
ResponseGps responseData = JSON.parseObject(responseStr, ResponseGps.class);
public class ResponseGps {
private String resCode;
private String resMsg;
private GpsVo data;
}
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。 原始发表:2023-02-09,如有侵权请联系 cloudcommunity@tencent 删除syntax服务接口errorexpect本文标签:
版权声明:本文标题:JSONObject.parseObjectsyntax error,expect START WITH { OR [,but actually START WITH error 内容由林淑君副主任自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.xiehuijuan.com/baike/1754980247a1708985.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。