-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Comments
Hi [ZuoxLiu], |
请求接口时,统一返回{code: 200, msg: "success", data: "ok"}因为格式是统一的,data是动态的,当判断code是200后,需要将data转换为特定的对象,当是其它对象时或返回的字符串不是"ok"是都没有问题,而data是"ok"时,返回上面的报错,需要对此字符串特殊处理。 |
"ok"这货都不是标准的JSON格式,不报错才有鬼! |
"ok"这货首先是个String,他跟"hello world"应该一样,获得相同的解析,可惜他不是 |
需要转义符, 这段代码是没问题的 String s = "\"ok\""; |
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)
The text was updated successfully, but these errors were encountered: