@@ -54,10 +54,10 @@ of this software and associated documentation files (the "Software"), to deal
54
54
* <p>
55
55
* This can sometimes be easier than using a JSONObject to build a string.
56
56
* @author JSON.org
57
- * @version 2010-12-24
57
+ * @version 2011-11-14
58
58
*/
59
59
public class JSONWriter {
60
- private static final int maxdepth = 20 ;
60
+ private static final int maxdepth = 200 ;
61
61
62
62
/**
63
63
* The comma flag determines if a comma should be output before the next
@@ -78,7 +78,7 @@ public class JSONWriter {
78
78
/**
79
79
* The object/array stack.
80
80
*/
81
- private JSONObject stack [];
81
+ private final JSONObject stack [];
82
82
83
83
/**
84
84
* The stack top index. A value of 0 indicates that the stack is empty.
@@ -157,7 +157,7 @@ public JSONWriter array() throws JSONException {
157
157
*/
158
158
private JSONWriter end (char mode , char c ) throws JSONException {
159
159
if (this .mode != mode ) {
160
- throw new JSONException (mode == 'a' ? "Misplaced endArray." :
160
+ throw new JSONException (mode == 'a' ? "Misplaced endArray." :
161
161
"Misplaced endObject." );
162
162
}
163
163
this .pop (mode );
@@ -204,7 +204,7 @@ public JSONWriter key(String string) throws JSONException {
204
204
}
205
205
if (this .mode == 'k' ) {
206
206
try {
207
- stack [top - 1 ].putOnce (string , Boolean .TRUE );
207
+ this . stack [this . top - 1 ].putOnce (string , Boolean .TRUE );
208
208
if (this .comma ) {
209
209
this .writer .write (',' );
210
210
}
@@ -259,7 +259,7 @@ private void pop(char c) throws JSONException {
259
259
throw new JSONException ("Nesting error." );
260
260
}
261
261
this .top -= 1 ;
262
- this .mode = this .top == 0 ?
262
+ this .mode = this .top == 0 ?
263
263
'd' : this .stack [this .top - 1 ] == null ? 'a' : 'k' ;
264
264
}
265
265
0 commit comments