Read an array of elements from the JSON input stream with elements as the specified type. @param type data type for deserialization (class or TypeToken) @return list of objects of the specified type deserialized from the JSON input stream NOTE : Returns null if the inp
(Type type)
| 705 | * @throws UncheckedIOException if an I/O exception is encountered |
| 706 | */ |
| 707 | @SuppressWarnings("unchecked") |
| 708 | public <T> List<T> readArray(Type type) { |
| 709 | List<T> toReturn = new ArrayList<>(); |
| 710 | BiFunction<JsonInput, PropertySetting, Object> elementCoercer = null; |
| 711 | |
| 712 | beginArray(); |
| 713 | while (hasNext()) { |
| 714 | // Resolved on the first element, so an empty array never needs a coercer for its type. |
| 715 | if (elementCoercer == null) { |
| 716 | elementCoercer = coercer.resolve(type); |
| 717 | } |
| 718 | toReturn.add((T) elementCoercer.apply(this, setter)); |
| 719 | } |
| 720 | endArray(); |
| 721 | |
| 722 | return toReturn; |
| 723 | } |
| 724 | |
| 725 | /** |
| 726 | * Determine if awaiting a JSON object property name. |