Returns the next available JsonElement on the reader. Null if none available. @return the next available JsonElement on the reader. Null if none available. @throws JsonParseException if the incoming stream is malformed JSON. @since 1.4
()
| 79 | * @since 1.4 |
| 80 | */ |
| 81 | public JsonElement next() throws JsonParseException { |
| 82 | if (!hasNext()) { |
| 83 | throw new NoSuchElementException(); |
| 84 | } |
| 85 | |
| 86 | try { |
| 87 | return Streams.parse(parser); |
| 88 | } catch (StackOverflowError e) { |
| 89 | throw new JsonParseException("Failed parsing JSON source to Json", e); |
| 90 | } catch (OutOfMemoryError e) { |
| 91 | throw new JsonParseException("Failed parsing JSON source to Json", e); |
| 92 | } catch (JsonParseException e) { |
| 93 | throw e.getCause() instanceof EOFException ? new NoSuchElementException() : e; |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | /** |
| 98 | * Returns true if a {@link JsonElement} is available on the input for consumption |