mirror of
https://github.com/ethauvin/JSON-java.git
synced 2025-06-17 07:50:52 -07:00
entityify
This commit is contained in:
parent
7c14a3d8c2
commit
f803a5db3e
1 changed files with 14 additions and 14 deletions
28
XML.java
28
XML.java
|
@ -31,11 +31,11 @@ import java.util.Iterator;
|
|||
* This provides static methods to convert an XML text into a JSONObject,
|
||||
* and to covert a JSONObject into an XML text.
|
||||
* @author JSON.org
|
||||
* @version 2011-02-11
|
||||
* @version 2012-10-26
|
||||
*/
|
||||
public class XML {
|
||||
|
||||
/** The Character '&'. */
|
||||
/** The Character '&'. */
|
||||
public static final Character AMP = new Character('&');
|
||||
|
||||
/** The Character '''. */
|
||||
|
@ -50,7 +50,7 @@ public class XML {
|
|||
/** The Character '>'. */
|
||||
public static final Character GT = new Character('>');
|
||||
|
||||
/** The Character '<'. */
|
||||
/** The Character '<'. */
|
||||
public static final Character LT = new Character('<');
|
||||
|
||||
/** The Character '?'. */
|
||||
|
@ -99,9 +99,9 @@ public class XML {
|
|||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Throw an exception if the string contains whitespace.
|
||||
* Throw an exception if the string contains whitespace.
|
||||
* Whitespace is not allowed in tagNames and attributes.
|
||||
* @param string
|
||||
* @throws JSONException
|
||||
|
@ -113,7 +113,7 @@ public class XML {
|
|||
}
|
||||
for (i = 0; i < length; i += 1) {
|
||||
if (Character.isWhitespace(string.charAt(i))) {
|
||||
throw new JSONException("'" + string +
|
||||
throw new JSONException("'" + string +
|
||||
"' contains a space character.");
|
||||
}
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ public class XML {
|
|||
token = x.nextToken();
|
||||
if (name == null) {
|
||||
throw x.syntaxError("Mismatched close tag " + token);
|
||||
}
|
||||
}
|
||||
if (!token.equals(name)) {
|
||||
throw x.syntaxError("Mismatched " + name + " and " + token);
|
||||
}
|
||||
|
@ -229,7 +229,7 @@ public class XML {
|
|||
if (!(token instanceof String)) {
|
||||
throw x.syntaxError("Missing value");
|
||||
}
|
||||
jsonobject.accumulate(string,
|
||||
jsonobject.accumulate(string,
|
||||
XML.stringToValue((String)token));
|
||||
token = null;
|
||||
} else {
|
||||
|
@ -262,7 +262,7 @@ public class XML {
|
|||
} else if (token instanceof String) {
|
||||
string = (String)token;
|
||||
if (string.length() > 0) {
|
||||
jsonobject.accumulate("content",
|
||||
jsonobject.accumulate("content",
|
||||
XML.stringToValue(string));
|
||||
}
|
||||
|
||||
|
@ -274,7 +274,7 @@ public class XML {
|
|||
context.accumulate(tagName, "");
|
||||
} else if (jsonobject.length() == 1 &&
|
||||
jsonobject.opt("content") != null) {
|
||||
context.accumulate(tagName,
|
||||
context.accumulate(tagName,
|
||||
jsonobject.opt("content"));
|
||||
} else {
|
||||
context.accumulate(tagName, jsonobject);
|
||||
|
@ -295,7 +295,7 @@ public class XML {
|
|||
* Try to convert a string into a number, boolean, or null. If the string
|
||||
* can't be converted, return the string. This is much less ambitious than
|
||||
* JSONObject.stringToValue, especially because it does not attempt to
|
||||
* convert plus forms, octal forms, hex forms, or E forms lacking decimal
|
||||
* convert plus forms, octal forms, hex forms, or E forms lacking decimal
|
||||
* points.
|
||||
* @param string A String.
|
||||
* @return A simple JSON value.
|
||||
|
@ -317,7 +317,7 @@ public class XML {
|
|||
return new Integer(0);
|
||||
}
|
||||
|
||||
// If it might be a number, try converting it. If that doesn't work,
|
||||
// If it might be a number, try converting it. If that doesn't work,
|
||||
// return the string.
|
||||
|
||||
try {
|
||||
|
@ -347,7 +347,7 @@ public class XML {
|
|||
return string;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Convert a well-formed (but not necessarily valid) XML string into a
|
||||
* JSONObject. Some information may be lost in this transformation
|
||||
|
@ -505,4 +505,4 @@ public class XML {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue