Begin appending a new object. All keys and values until the balancing endObject will be appended to this object. The endObject method must be called to mark the object's end. @return this @throws JSONException If the nesting is too deep, or if the object is started in
()
| 226 | * outermost array or object). |
| 227 | */ |
| 228 | public JSONWriter object() throws JSONException { |
| 229 | if (this.mode == 'i') { |
| 230 | this.mode = 'o'; |
| 231 | } |
| 232 | if (this.mode == 'o' || this.mode == 'a') { |
| 233 | this.append("{"); |
| 234 | this.push(new JSONObject()); |
| 235 | this.comma = false; |
| 236 | return this; |
| 237 | } |
| 238 | throw new JSONException("Misplaced object."); |
| 239 | |
| 240 | } |
| 241 | |
| 242 | /** |
| 243 | * Pop an array or object scope. |