Skip to content

Commit

Permalink
非标准json字符串,不格式化输出 fix #463
Browse files Browse the repository at this point in the history
  • Loading branch information
liujingxing committed Sep 21, 2023
1 parent f53e5f9 commit d8aa537
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions rxhttp/src/main/java/rxhttp/wrapper/utils/LogUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,17 @@ private static String formattingJson(String json, int indentSpaces) {
try {
if (json.startsWith("[")) {
JSONArray jsonObject = new JSONArray(json);
if (jsonObject.toString().length() < json.length()) {
//https://github.com/liujingxing/rxhttp/issues/463
return json;
}
return new JSONStringer(indentSpaces).write(jsonObject).toString();
} else if (json.startsWith("{")) {
JSONObject jsonObject = new JSONObject(json);
if (jsonObject.toString().length() < json.length()) {
//https://github.com/liujingxing/rxhttp/issues/463
return json;
}
return new JSONStringer(indentSpaces).write(jsonObject).toString();
}
} catch (Throwable ignore) {
Expand Down

0 comments on commit d8aa537

Please sign in to comment.