1
0
Fork 0
mirror of https://github.com/ethauvin/JSON-java.git synced 2025-06-17 07:50:52 -07:00

Merge pull request #495 from harkue/master

fix typo
This commit is contained in:
Sean Leary 2019-11-20 11:20:18 -06:00 committed by GitHub
commit dd7056cb6d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 30 deletions

View file

@ -1409,7 +1409,7 @@ public class JSONArray implements Iterable<Object> {
public Writer write(Writer writer, int indentFactor, int indent) public Writer write(Writer writer, int indentFactor, int indent)
throws JSONException { throws JSONException {
try { try {
boolean commanate = false; boolean needsComma = false;
int length = this.length(); int length = this.length();
writer.write('['); writer.write('[');
@ -1421,23 +1421,23 @@ public class JSONArray implements Iterable<Object> {
throw new JSONException("Unable to write JSONArray value at index: 0", e); throw new JSONException("Unable to write JSONArray value at index: 0", e);
} }
} else if (length != 0) { } else if (length != 0) {
final int newindent = indent + indentFactor; final int newIndent = indent + indentFactor;
for (int i = 0; i < length; i += 1) { for (int i = 0; i < length; i += 1) {
if (commanate) { if (needsComma) {
writer.write(','); writer.write(',');
} }
if (indentFactor > 0) { if (indentFactor > 0) {
writer.write('\n'); writer.write('\n');
} }
JSONObject.indent(writer, newindent); JSONObject.indent(writer, newIndent);
try { try {
JSONObject.writeValue(writer, this.myArrayList.get(i), JSONObject.writeValue(writer, this.myArrayList.get(i),
indentFactor, newindent); indentFactor, newIndent);
} catch (Exception e) { } catch (Exception e) {
throw new JSONException("Unable to write JSONArray value at index: " + i, e); throw new JSONException("Unable to write JSONArray value at index: " + i, e);
} }
commanate = true; needsComma = true;
} }
if (indentFactor > 0) { if (indentFactor > 0) {
writer.write('\n'); writer.write('\n');

View file

@ -2141,7 +2141,7 @@ public class JSONObject {
//} //}
//return new BigInteger(val); //return new BigInteger(val);
// BigInteger version: We use a similar bitLenth compare as // BigInteger version: We use a similar bitLength compare as
// BigInteger#intValueExact uses. Increases GC, but objects hold // BigInteger#intValueExact uses. Increases GC, but objects hold
// only what they need. i.e. Less runtime overhead if the value is // only what they need. i.e. Less runtime overhead if the value is
// long lived. Which is the better tradeoff? This is closer to what's // long lived. Which is the better tradeoff? This is closer to what's
@ -2496,7 +2496,7 @@ public class JSONObject {
public Writer write(Writer writer, int indentFactor, int indent) public Writer write(Writer writer, int indentFactor, int indent)
throws JSONException { throws JSONException {
try { try {
boolean commanate = false; boolean needsComma = false;
final int length = this.length(); final int length = this.length();
writer.write('{'); writer.write('{');
@ -2514,15 +2514,15 @@ public class JSONObject {
throw new JSONException("Unable to write JSONObject value for key: " + key, e); throw new JSONException("Unable to write JSONObject value for key: " + key, e);
} }
} else if (length != 0) { } else if (length != 0) {
final int newindent = indent + indentFactor; final int newIndent = indent + indentFactor;
for (final Entry<String,?> entry : this.entrySet()) { for (final Entry<String,?> entry : this.entrySet()) {
if (commanate) { if (needsComma) {
writer.write(','); writer.write(',');
} }
if (indentFactor > 0) { if (indentFactor > 0) {
writer.write('\n'); writer.write('\n');
} }
indent(writer, newindent); indent(writer, newIndent);
final String key = entry.getKey(); final String key = entry.getKey();
writer.write(quote(key)); writer.write(quote(key));
writer.write(':'); writer.write(':');
@ -2530,11 +2530,11 @@ public class JSONObject {
writer.write(' '); writer.write(' ');
} }
try { try {
writeValue(writer, entry.getValue(), indentFactor, newindent); writeValue(writer, entry.getValue(), indentFactor, newIndent);
} catch (Exception e) { } catch (Exception e) {
throw new JSONException("Unable to write JSONObject value for key: " + key, e); throw new JSONException("Unable to write JSONObject value for key: " + key, e);
} }
commanate = true; needsComma = true;
} }
if (indentFactor > 0) { if (indentFactor > 0) {
writer.write('\n'); writer.write('\n');

View file

@ -66,7 +66,7 @@ public class XML {
public static final Character SLASH = '/'; public static final Character SLASH = '/';
/** /**
* Null attrubute name * Null attribute name
*/ */
public static final String NULL_ATTR = "xsi:nil"; public static final String NULL_ATTR = "xsi:nil";
@ -251,7 +251,7 @@ public class XML {
throws JSONException { throws JSONException {
char c; char c;
int i; int i;
JSONObject jsonobject = null; JSONObject jsonObject = null;
String string; String string;
String tagName; String tagName;
Object token; Object token;
@ -332,7 +332,7 @@ public class XML {
} else { } else {
tagName = (String) token; tagName = (String) token;
token = null; token = null;
jsonobject = new JSONObject(); jsonObject = new JSONObject();
boolean nilAttributeFound = false; boolean nilAttributeFound = false;
for (;;) { for (;;) {
if (token == null) { if (token == null) {
@ -353,14 +353,14 @@ public class XML {
&& Boolean.parseBoolean((String) token)) { && Boolean.parseBoolean((String) token)) {
nilAttributeFound = true; nilAttributeFound = true;
} else if (!nilAttributeFound) { } else if (!nilAttributeFound) {
jsonobject.accumulate(string, jsonObject.accumulate(string,
config.keepStrings config.keepStrings
? ((String) token) ? ((String) token)
: stringToValue((String) token)); : stringToValue((String) token));
} }
token = null; token = null;
} else { } else {
jsonobject.accumulate(string, ""); jsonObject.accumulate(string, "");
} }
@ -371,8 +371,8 @@ public class XML {
} }
if (nilAttributeFound) { if (nilAttributeFound) {
context.accumulate(tagName, JSONObject.NULL); context.accumulate(tagName, JSONObject.NULL);
} else if (jsonobject.length() > 0) { } else if (jsonObject.length() > 0) {
context.accumulate(tagName, jsonobject); context.accumulate(tagName, jsonObject);
} else { } else {
context.accumulate(tagName, ""); context.accumulate(tagName, "");
} }
@ -390,21 +390,20 @@ public class XML {
} else if (token instanceof String) { } else if (token instanceof String) {
string = (String) token; string = (String) token;
if (string.length() > 0) { if (string.length() > 0) {
jsonobject.accumulate(config.cDataTagName, jsonObject.accumulate(config.cDataTagName,
config.keepStrings ? string : stringToValue(string)); config.keepStrings ? string : stringToValue(string));
} }
} else if (token == LT) { } else if (token == LT) {
// Nested element // Nested element
if (parse(x, jsonobject, tagName, config)) { if (parse(x, jsonObject, tagName, config)) {
if (jsonobject.length() == 0) { if (jsonObject.length() == 0) {
context.accumulate(tagName, ""); context.accumulate(tagName, "");
} else if (jsonobject.length() == 1 } else if (jsonObject.length() == 1
&& jsonobject.opt(config.cDataTagName) != null) { && jsonObject.opt(config.cDataTagName) != null) {
context.accumulate(tagName, context.accumulate(tagName, jsonObject.opt(config.cDataTagName));
jsonobject.opt(config.cDataTagName));
} else { } else {
context.accumulate(tagName, jsonobject); context.accumulate(tagName, jsonObject);
} }
return false; return false;
} }
@ -731,7 +730,7 @@ public class XML {
} }
if (tagName != null) { if (tagName != null) {
// Emit the </tagname> close tag // Emit the </tagName> close tag
sb.append("</"); sb.append("</");
sb.append(tagName); sb.append(tagName);
sb.append('>'); sb.append('>');

View file

@ -152,7 +152,7 @@ public class XMLTokener extends JSONTokener {
} }
/** /**
* Unescapes an XML entity encoding; * Unescape an XML entity encoding;
* @param e entity (only the actual entity value, not the preceding & or ending ; * @param e entity (only the actual entity value, not the preceding & or ending ;
* @return * @return
*/ */