From 9bb26bdb34ba746eb038abc856cf05dafbe4adf4 Mon Sep 17 00:00:00 2001 From: marilynel Date: Sun, 3 Aug 2025 11:52:20 -0800 Subject: [PATCH] sonar cube stuff --- src/main/java/org/json/JSONObject.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/json/JSONObject.java b/src/main/java/org/json/JSONObject.java index d852586..1b5161e 100644 --- a/src/main/java/org/json/JSONObject.java +++ b/src/main/java/org/json/JSONObject.java @@ -480,6 +480,7 @@ public class JSONObject { try { this.putOpt(name, c.getField(name).get(object)); } catch (Exception ignore) { + // if invalid, do not include key:value pair in JSONObject } } } @@ -651,9 +652,9 @@ public class JSONObject { return "null"; } -// Shave off trailing zeros and decimal point, if possible. - + // Shave off trailing zeros and decimal point, if possible. String string = Double.toString(d); + // idx = 0 case is covered by behavior of Double.toString() if (string.indexOf('.') > 0 && string.indexOf('e') < 0 && string.indexOf('E') < 0) { while (string.endsWith("0")) { @@ -1130,8 +1131,8 @@ public class JSONObject { testValidity(number); // Shave off trailing zeros and decimal point, if possible. - String string = number.toString(); + // idx = 0 case is covered by behavior of .toString() if (string.indexOf('.') > 0 && string.indexOf('e') < 0 && string.indexOf('E') < 0) { while (string.endsWith("0")) {