Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions XML.java
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ public static String toString(Object object) throws JSONException {
* @return A string.
* @throws JSONException
*/
public static String toString(Object object, String tagName)
public static String toString(Object object, String originalTagName)
throws JSONException {
StringBuilder sb = new StringBuilder();
int i;
Expand All @@ -387,11 +387,20 @@ public static String toString(Object object, String tagName)
int length;
String string;
Object value;
String tagName;

tagName = originalTagName;
if (tagName != null)
{
//replace leading digits with n_
tagName = tagName.replaceFirst("^(\\d)", "n_$1");
}

if (object instanceof JSONObject) {

// Emit <tagName>

if (tagName != null) {
if (tagName != null) {
sb.append('<');
sb.append(tagName);
sb.append('>');
Expand Down