浏览代码

util: Ignore spaces in JSON string

Peter Cai 1 年之前
父节点
当前提交
426e5c0197
共有 1 个文件被更改,包括 5 次插入0 次删除
  1. 5 0
      app-common/src/main/java/im/angry/openeuicc/util/StringUtils.kt

+ 5 - 0
app-common/src/main/java/im/angry/openeuicc/util/StringUtils.kt

@@ -81,6 +81,11 @@ fun String.prettyPrintJson(): String {
                 inQuotes = !inQuotes
             }
 
+            !inQuotes && c == ' ' -> {
+                // Do nothing -- we ignore spaces outside of quotes by default
+                // This is to ensure predictable formatting
+            }
+
             else -> ret.append(c)
         }