Skip to content

Commit 75419e3

Browse files
committed
refactor: introduce explaining variable 'indentationSuffix' in XML.toString()
1 parent 097a401 commit 75419e3

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/main/java/org/json/XML.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -847,14 +847,14 @@ private static String toString(final Object object, final String tagName, final
847847

848848

849849
string = (object == null) ? "null" : escape(object.toString());
850-
850+
String indentationSuffix = (indentFactor > 0) ? "\n" : "";
851851
if(tagName == null){
852-
return indent(indent) + "\"" + string + "\"" + ((indentFactor > 0) ? "\n" : "");
852+
return indent(indent) + "\"" + string + "\"" + indentationSuffix;
853853
} else if(string.length() == 0){
854-
return indent(indent) + "<" + tagName + "/>" + ((indentFactor > 0) ? "\n" : "");
854+
return indent(indent) + "<" + tagName + "/>" + indentationSuffix;
855855
} else {
856856
return indent(indent) + "<" + tagName
857-
+ ">" + string + "</" + tagName + ">" + ((indentFactor > 0) ? "\n" : "");
857+
+ ">" + string + "</" + tagName + ">" + indentationSuffix;
858858
}
859859
}
860860

0 commit comments

Comments
 (0)