Browse Source

util: Ignore spaces in JSON string

Peter Cai 1 year ago
parent
commit
426e5c0197
1 changed files with 5 additions and 0 deletions
  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 = !inQuotes
             }
             }
 
 
+            !inQuotes && c == ' ' -> {
+                // Do nothing -- we ignore spaces outside of quotes by default
+                // This is to ensure predictable formatting
+            }
+
             else -> ret.append(c)
             else -> ret.append(c)
         }
         }