Skip to content

Commit 5dc1031

Browse files
committed
Made JSONMl constructor to private and refactored ternary operations to independent statement in L243
1 parent 1de42aa commit 5dc1031

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

src/main/java/org/json/JSONML.java

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ public class JSONML {
1717
/**
1818
* Constructs a new JSONML object.
1919
*/
20-
public JSONML() {
20+
private JSONML() {
2121
}
2222

23+
2324
/**
2425
* Parse XML values and store them in a JSONArray.
2526
* @param x The XMLTokener containing the source string.
@@ -239,9 +240,21 @@ private static Object parse(
239240
}
240241
} else {
241242
if (ja != null) {
242-
ja.put(token instanceof String
243-
? (config.isKeepStrings() ? XML.unescape((String)token) : XML.stringToValue((String)token))
244-
: token);
243+
Object value;
244+
245+
if (token instanceof String) {
246+
String strToken = (String) token;
247+
if (config.isKeepStrings()) {
248+
value = XML.unescape(strToken);
249+
} else {
250+
value = XML.stringToValue(strToken);
251+
}
252+
} else {
253+
value = token;
254+
}
255+
256+
ja.put(value);
257+
245258
}
246259
}
247260
}

0 commit comments

Comments
 (0)