Read the next element from the JSON input stream as the specified type. @param type data type for deserialization (class or TypeToken) @return object of the specified type deserialized from the JSON input stream NOTE : Returns null if the input string is exhausted. @pa
(Type type)
| 447 | * @throws UncheckedIOException if an I/O exception is encountered |
| 448 | */ |
| 449 | public <T> @Nullable T read(Type type) { |
| 450 | markReadPerformed(); |
| 451 | skipWhitespace(input); |
| 452 | |
| 453 | // Guard against reading an empty stream |
| 454 | if (input.peek() == Input.EOF) { |
| 455 | return null; |
| 456 | } |
| 457 | |
| 458 | return coercer.coerce(this, type, setter); |
| 459 | } |
| 460 | |
| 461 | public <T> T readNonNull(Type type) { |
| 462 | return requireNonNull(read(type)); |