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)
| 506 | * @throws UncheckedIOException if an I/O exception is encountered |
| 507 | */ |
| 508 | public <T> @Nullable T read(Type type) { |
| 509 | markReadPerformed(); |
| 510 | skipWhitespace(input); |
| 511 | |
| 512 | // Guard against reading an empty stream |
| 513 | if (input.peek() == Input.EOF) { |
| 514 | return null; |
| 515 | } |
| 516 | |
| 517 | return coercer.coerce(this, type, setter); |
| 518 | } |
| 519 | |
| 520 | public <T> T readNonNull(Type type) { |
| 521 | return requireNonNull(read(type)); |