Implemented automatic stripping of newline characters when loading JSON objects.
authorMarco Zanon <info@marcozanon.com>
Thu, 29 Feb 2024 15:32:17 +0000 (15:32 +0000)
committerMarco Zanon <info@marcozanon.com>
Thu, 29 Feb 2024 15:32:17 +0000 (15:32 +0000)
9.x/CHANGELOG
9.x/src/main/java/com/marcozanon/macaco/json/MJsonArray.java
9.x/src/main/java/com/marcozanon/macaco/json/MJsonBoolean.java
9.x/src/main/java/com/marcozanon/macaco/json/MJsonNull.java
9.x/src/main/java/com/marcozanon/macaco/json/MJsonNumber.java
9.x/src/main/java/com/marcozanon/macaco/json/MJsonObject.java
9.x/src/main/java/com/marcozanon/macaco/json/MJsonString.java

index 5fae8063999bd9994c2955ae3f7382cdcdc7fc53..4a8a66018980d6b9cbdb2fac3cfc0db3f74bd828 100644 (file)
@@ -5,6 +5,7 @@ See LICENSE for details.
 ------------------
 9.1.0 (2024-02-29)
 ------------------
+* Implemented automatic stripping of newline characters when loading JSON objects.
 * Upgraded copyright notice to year 2024.
 
 ==================
index f452fb2dda7cfd389401be1e79ac017cdae1fc0b..7b0a138fa487e9409b9da5aa03d92d3867397f51 100644 (file)
@@ -126,6 +126,8 @@ public class MJsonArray extends MJsonValue {
             throw new IllegalArgumentException("Invalid 'x': null or empty.");
         }
         //
+        x = x.replaceAll("\\R", "");
+        //
         if ((2 > x.length()) || ('[' != x.charAt(0)) || (']' != x.charAt(x.length() - 1))) {
             throw new MInvalidJsonValueException(String.format("Invalid 'x': %s: must begin and end with square brackets.", x));
         }
index 39f48b0957eb597f31fcee44549bb60a74351042..0acb608d9eefff5f4dbc0791bbf73851e40955f0 100644 (file)
@@ -73,6 +73,8 @@ public class MJsonBoolean extends MJsonValue {
             throw new IllegalArgumentException("Invalid 'x': null or empty.");
         }
         //
+        x = x.replaceAll("\\R", "");
+        //
         if ((!"true".equals(x)) && (!"false".equals(x))) {
             throw new MInvalidJsonValueException(String.format("Invalid 'x': %s: not a Json boolean.", x));
         }
index e395c33fd4c6ddc9875d27ec48a0360fe11fc831..ab8a0548cbabb8667e8bf09b2cfea46ddac76fe6 100644 (file)
@@ -54,6 +54,8 @@ public class MJsonNull extends MJsonValue {
             throw new IllegalArgumentException("Invalid 'x': null or empty.");
         }
         //
+        x = x.replaceAll("\\R", "");
+        //
         if (!"null".equals(x)) {
             throw new MInvalidJsonValueException(String.format("Invalid 'x': %s: not a Json null.", x));
         }
index 87d04e1186e7b26f1f238af27e515c33090d9165..11c68c699c9b8154acb839a30af081b9c8f38df5 100644 (file)
@@ -91,6 +91,8 @@ public class MJsonNumber extends MJsonValue {
             throw new IllegalArgumentException("Invalid 'x': null or empty.");
         }
         //
+        x = x.replaceAll("\\R", "");
+        //
         BigDecimal y = null;
         //
         try {
index 2f4fd886d4a777ab81f9f7a2f484d0525bee2f56..58bea7f631c0ac586ef2d99637787bca0fd002e1 100644 (file)
@@ -146,6 +146,8 @@ public class MJsonObject extends MJsonValue {
             throw new IllegalArgumentException("Invalid 'x': null or empty.");
         }
         //
+        x = x.replaceAll("\\R", "");
+        //
         if ((2 > x.length()) || ('{' != x.charAt(0)) || ('}' != x.charAt(x.length() - 1))) {
             throw new MInvalidJsonValueException(String.format("Invalid 'x': %s: must begin and end with curly brackets.", x));
         }
index 75d7035729e19d318de00dec07471d20522fd826..5f3108c5771c42afca40805410f1f1e88a10aec2 100644 (file)
@@ -281,6 +281,8 @@ public class MJsonString extends MJsonValue {
             throw new IllegalArgumentException("Invalid 'x': null or empty.");
         }
         //
+        x = x.replaceAll("\\R", "");
+        //
         if ((2 > x.length()) || ('"' != x.charAt(0)) || ('"' != x.charAt(x.length() - 1))) {
             throw new MInvalidJsonValueException(String.format("Invalid 'x': %s: not a Json string.", x));
         }