@@ -69,9 +69,13 @@ public interface JsonType<T> extends JsonView<T> {
6969 JsonType <List <T >> list ();
7070
7171 /**
72- * Return the stream type for this JsonType .
72+ * Prefer use of {@link JsonType# stream(JsonReader)} rather than using this stream type directly .
7373 * <p>
74- * When using this Stream type use a try-with-resources block with the Stream
74+ * Generally, we should not use this type directly but instead create a {@link JsonReader}
75+ * and use {@link JsonType#stream(JsonReader)} instead. Then we just use a try-with-resources on
76+ * the JsonReader and can additionally specify {@link JsonReader#streamArray(boolean)} option.
77+ * <p>
78+ * When using this Stream type directly, use a try-with-resources block with the Stream
7579 * to ensure that any underlying resources are closed.
7680 *
7781 * <pre>{@code
@@ -84,6 +88,9 @@ public interface JsonType<T> extends JsonView<T> {
8488 * }
8589 *
8690 * }</pre>
91+ *
92+ * @return The stream type for this base JsonType.
93+ * @see #stream(JsonReader)
8794 */
8895 JsonType <Stream <T >> stream ();
8996
@@ -142,12 +149,32 @@ public interface JsonType<T> extends JsonView<T> {
142149 * JsonType<MyBean> type = jsonb.type(MyBean.class);
143150 *
144151 * try (JsonReader reader = jsonb.reader(content)) {
145-
152+ *
146153 * Stream<MyBean> asStream = type.stream(reader);
147154 * ...
148155 * }
149156 *
150157 * }</pre>
158+ *
159+ * <h3>When using Jackson</h3>
160+ * <p>
161+ * When using Jackson-core as the underlying parser we should explicitly state that the content is either
162+ * an ARRAY (with '[' and ']' tokens or not (x-json-stream new line delimited, there are no '[' and ']' tokens).
163+ * <p>
164+ * When using the builtin avaje-jsonb parser, it automatically detects and handles both cases (with or without the
165+ * '[' and ']' tokens). With the Jackson-core parser we need to explicitly state if we are processing
166+ *
167+ * <pre>{@code
168+ *
169+ * JsonType<MyBean> type = jsonb.type(MyBean.class);
170+ *
171+ * try (JsonReader reader = jsonb.reader(content)) {
172+ * // when the content contains the ARRAY '[', ']' tokens set streamArray(true)
173+ * Stream<MyBean> asStream = type.stream(reader.streamArray(true));
174+ * ...
175+ * }
176+ *
177+ * }</pre>
151178 */
152179 Stream <T > stream (JsonReader reader );
153180
0 commit comments