{@inheritDoc} @throws JsonException if JSON stream isn't empty or an I/O exception is encountered @throws java.util.NoSuchElementException if serialization object stack is empty
()
| 441 | * @throws java.util.NoSuchElementException if serialization object stack is empty |
| 442 | */ |
| 443 | @Override |
| 444 | public void close() { |
| 445 | if (appendable instanceof Closeable) { |
| 446 | try { |
| 447 | ((Closeable) appendable).close(); |
| 448 | } catch (IOException e) { |
| 449 | throw new JsonException(e); |
| 450 | } |
| 451 | } |
| 452 | |
| 453 | if (!(stack.getFirst() instanceof Root)) { |
| 454 | throw new JsonException("Attempting to close incomplete json stream"); |
| 455 | } |
| 456 | } |
| 457 | |
| 458 | private JsonOutput append(String text) { |
| 459 | stack.getFirst().write(text); |