【发布时间】:2021-02-11 07:42:48
【问题描述】:
我正在调用 API 并得到响应
"{\r\n \"wrongUserLogInIdOrPassword\": true,\r\n \"isEmailVerificationRequired\": false,\r\n \"displayEmail\": null,\r\n \"isPhoneVerificationRequired\": false,\r\n \"displayPhone\": null,\r\n \"isUserLockedOut\": false,\r\n \"lockedOutEndDateTime\": 0,\r\n \"isProgressToken\": false,\r\n \"progressToken\": null,\r\n \"isSecondPasswordRequired\": false,\r\n \"secondPasswordToken\": null,\r\n \"isTwoFactorRequired\": false,\r\n \"twoFactorToken\": null,\r\n \"logInId\": {\r\n \"value\": \"xxxx@gmail.com\",\r\n \"error\": \"Wrong Login id or password\"\r\n },\r\n \"password\": {\r\n \"value\": \"\",\r\n \"error\": \"Wrong Login id or password\"\r\n },\r\n \"invalidData\": false,\r\n \"somethingWentWrong\": false,\r\n \"error\": null\r\n}"
然后我尝试使用这个来转换 JSON 对象中的响应
v = v.replaceAll("(\r\n|\n)", "");
return new JSONObject(v).toString();
我也尝试替换“\n\r”,但它不起作用。
谁能帮忙?
【问题讨论】:
-
你为 JSON 使用哪个库?
-
@Getodac 我正在使用 org.json.JSONObject