Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON.parseObject("ok", String.class) 为什么总是报错,是啥原因呢 #4503

Open
ZuoxLiu opened this issue Apr 26, 2024 · 2 comments
Open

Comments

@ZuoxLiu
Copy link

ZuoxLiu commented Apr 26, 2024

com.alibaba.fastjson.JSONException: illegal input : o, offset 1, character o, line 1, column 1, fastjson-version 2.0.47 ok
at com.alibaba.fastjson.JSON.parseObject(JSON.java:525)

@MandarGharse
Copy link

Hi [ZuoxLiu],
What is the expected output ? The error is because "ok" is not a valid json string

@ZuoxLiu
Copy link
Author

ZuoxLiu commented May 4, 2024

Hi [ZuoxLiu], What is the expected output ? The error is because "ok" is not a valid json string

请求接口时,统一返回{code: 200, msg: "success", data: "ok"}因为格式是统一的,data是动态的,当判断code是200后,需要将data转换为特定的对象,当是其它对象时或返回的字符串不是"ok"是都没有问题,而data是"ok"时,返回上面的报错,需要对此字符串特殊处理。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants