From: Marco Zanon Date: Thu, 29 Feb 2024 15:32:17 +0000 (+0000) Subject: Implemented automatic stripping of newline characters when loading JSON objects. X-Git-Tag: SVN-to-Git~17 X-Git-Url: https://gitweb.marcozanon.com/?a=commitdiff_plain;h=9559e439ec038a318ce9c8668413cbd04834c8eb;p=Macaco Implemented automatic stripping of newline characters when loading JSON objects. --- diff --git a/9.x/CHANGELOG b/9.x/CHANGELOG index 5fae806..4a8a660 100644 --- a/9.x/CHANGELOG +++ b/9.x/CHANGELOG @@ -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. ================== diff --git a/9.x/src/main/java/com/marcozanon/macaco/json/MJsonArray.java b/9.x/src/main/java/com/marcozanon/macaco/json/MJsonArray.java index f452fb2..7b0a138 100644 --- a/9.x/src/main/java/com/marcozanon/macaco/json/MJsonArray.java +++ b/9.x/src/main/java/com/marcozanon/macaco/json/MJsonArray.java @@ -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)); } diff --git a/9.x/src/main/java/com/marcozanon/macaco/json/MJsonBoolean.java b/9.x/src/main/java/com/marcozanon/macaco/json/MJsonBoolean.java index 39f48b0..0acb608 100644 --- a/9.x/src/main/java/com/marcozanon/macaco/json/MJsonBoolean.java +++ b/9.x/src/main/java/com/marcozanon/macaco/json/MJsonBoolean.java @@ -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)); } diff --git a/9.x/src/main/java/com/marcozanon/macaco/json/MJsonNull.java b/9.x/src/main/java/com/marcozanon/macaco/json/MJsonNull.java index e395c33..ab8a054 100644 --- a/9.x/src/main/java/com/marcozanon/macaco/json/MJsonNull.java +++ b/9.x/src/main/java/com/marcozanon/macaco/json/MJsonNull.java @@ -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)); } diff --git a/9.x/src/main/java/com/marcozanon/macaco/json/MJsonNumber.java b/9.x/src/main/java/com/marcozanon/macaco/json/MJsonNumber.java index 87d04e1..11c68c6 100644 --- a/9.x/src/main/java/com/marcozanon/macaco/json/MJsonNumber.java +++ b/9.x/src/main/java/com/marcozanon/macaco/json/MJsonNumber.java @@ -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 { diff --git a/9.x/src/main/java/com/marcozanon/macaco/json/MJsonObject.java b/9.x/src/main/java/com/marcozanon/macaco/json/MJsonObject.java index 2f4fd88..58bea7f 100644 --- a/9.x/src/main/java/com/marcozanon/macaco/json/MJsonObject.java +++ b/9.x/src/main/java/com/marcozanon/macaco/json/MJsonObject.java @@ -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)); } diff --git a/9.x/src/main/java/com/marcozanon/macaco/json/MJsonString.java b/9.x/src/main/java/com/marcozanon/macaco/json/MJsonString.java index 75d7035..5f3108c 100644 --- a/9.x/src/main/java/com/marcozanon/macaco/json/MJsonString.java +++ b/9.x/src/main/java/com/marcozanon/macaco/json/MJsonString.java @@ -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)); }