End the current JSON object. @return this JsonOutput object @throws JsonException if top item on serialization object stack isn't a JsonObject @throws java.util.NoSuchElementException if serialization object stack is empty
()
| 333 | * @throws java.util.NoSuchElementException if serialization object stack is empty |
| 334 | */ |
| 335 | public JsonOutput endObject() { |
| 336 | Node topOfStack = stack.getFirst(); |
| 337 | if (!(topOfStack instanceof JsonObject)) { |
| 338 | throw new JsonException("Attempt to close a json object, but not writing a json object"); |
| 339 | } |
| 340 | stack.removeFirst(); |
| 341 | indent = indent.substring(0, indent.length() - indentBy.length()); |
| 342 | |
| 343 | if (!topOfStack.isEmpty) { |
| 344 | rawAppend(lineSeparator); |
| 345 | rawAppend(indent); |
| 346 | } else { |
| 347 | rawAppend(indent); |
| 348 | } |
| 349 | rawAppend("}"); |
| 350 | return this; |
| 351 | } |
| 352 | |
| 353 | /** |
| 354 | * Begin a new JSON array. |
no test coverage detected