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)
| 670 | * @throws UncheckedIOException if an I/O exception is encountered |
| 671 | */ |
| 672 | public <T> @Nullable T read(Type type) { |
| 673 | markReadPerformed(); |
| 674 | skipWhitespace(input); |
| 675 | |
| 676 | // Guard against reading an empty stream |
| 677 | if (input.peek() == Input.EOF) { |
| 678 | return null; |
| 679 | } |
| 680 | |
| 681 | return coercer.coerce(this, type, setter); |
| 682 | } |
| 683 | |
| 684 | public <T> T readNonNull(Type type) { |
| 685 | return requireNonNull(read(type)); |