RandomSec/main/lib-src/patches/json-20100208.patch

44 lines
1.5 KiB
Diff
Raw Normal View History

diff -rupN org/json/JSONWriter.java json/src/org/json/JSONWriter.java
--- org/json/JSONWriter.java 2010-01-30 15:13:38.000000000 -0800
+++ json/src/org/json/JSONWriter.java 2010-09-16 16:59:11.000000000 -0700
@@ -57,7 +57,7 @@ SOFTWARE.
* @version 2008-09-22
*/
public class JSONWriter {
- private static final int maxdepth = 20;
+ private static final int maxdepth = 100;
/**
* The comma flag determines if a comma should be output before the next
@@ -91,12 +91,19 @@ public class JSONWriter {
protected Writer writer;
/**
- * Make a fresh JSONWriter. It can be used to build one JSON text.
+ * Make a fresh JSONWriter at the default maximum depth. It can be used to build one JSON text.
*/
public JSONWriter(Writer w) {
+ this(w, maxdepth);
+ }
+
+ /**
+ * Make a fresh JSONWriter at the given maximum depth. It can be used to build one JSON text.
+ */
+ public JSONWriter(Writer w, int depth) {
this.comma = false;
this.mode = 'i';
- this.stack = new JSONObject[maxdepth];
+ this.stack = new JSONObject[depth];
this.top = 0;
this.writer = w;
}
@@ -268,7 +275,7 @@ public class JSONWriter {
* @throws JSONException If nesting is too deep.
*/
private void push(JSONObject jo) throws JSONException {
- if (this.top >= maxdepth) {
+ if (this.top >= this.stack.length) {
throw new JSONException("Nesting too deep.");
}
this.stack[this.top] = jo;