Closes the current scope by appending any necessary whitespace and the given bracket.
(JsonScope empty, JsonScope nonempty, String closeBracket)
| 271 | * given bracket. |
| 272 | */ |
| 273 | private JsonWriter close(JsonScope empty, JsonScope nonempty, String closeBracket) |
| 274 | throws IOException { |
| 275 | JsonScope context = peek(); |
| 276 | if (context != nonempty && context != empty) { |
| 277 | throw new IllegalStateException("Nesting problem: " + stack); |
| 278 | } |
| 279 | |
| 280 | stack.remove(stack.size() - 1); |
| 281 | if (context == nonempty) { |
| 282 | newline(); |
| 283 | } |
| 284 | out.write(closeBracket); |
| 285 | return this; |
| 286 | } |
| 287 | |
| 288 | /** |
| 289 | * Returns the value on the top of the stack. |