@@ -2367,11 +2367,14 @@ public <T> T readValue(JsonParser p, JavaType valueType)
2367
2367
}
2368
2368
2369
2369
/**
2370
- * Method to deserialize JSON content as tree expressed
2371
- * using set of {@link JsonNode} instances. Returns
2372
- * root of the resulting tree (where root can consist
2373
- * of just a single node if the current event is a
2374
- * value event, not container).
2370
+ * Method to deserialize JSON content as a tree {@link JsonNode}.
2371
+ * Returns {@link JsonNode} that represents the root of the resulting tree, if there
2372
+ * was content to read, or {@code null} if no more content is accessible
2373
+ * via passed {@link JsonParser}.
2374
+ *<p>
2375
+ * NOTE! Behavior with end-of-input (no more content) differs between this
2376
+ * {@code readTree} method, and all other methods that take input source: latter
2377
+ * will return "missing node", NOT {@code null}
2375
2378
*
2376
2379
* @return a {@link JsonNode}, if valid JSON content found; null
2377
2380
* if input has no content to bind -- note, however, that if
@@ -2523,105 +2526,40 @@ public JsonNode readTree(InputStream in) throws IOException
2523
2526
}
2524
2527
2525
2528
/**
2526
- * Method to deserialize JSON content as tree expressed
2527
- * using set of {@link JsonNode} instances.
2528
- * Returns root of the resulting tree (where root can consist
2529
- * of just a single node if the current event is a
2530
- * value event, not container).
2531
- *<p>
2532
- * If a low-level I/O problem (missing input, network error) occurs,
2533
- * a {@link IOException} will be thrown.
2534
- * If a parsing problem occurs (invalid JSON),
2535
- * {@link JsonParseException} will be thrown.
2536
- * If no content is found from input (end-of-input), Java
2537
- * <code>null</code> will be returned.
2538
- *
2539
- * @param r Reader used to read JSON content
2540
- * for building the JSON tree.
2541
- *
2542
- * @return a {@link JsonNode}, if valid JSON content found; null
2543
- * if input has no content to bind -- note, however, that if
2544
- * JSON <code>null</code> token is found, it will be represented
2545
- * as a non-null {@link JsonNode} (one that returns <code>true</code>
2546
- * for {@link JsonNode#isNull()}
2529
+ * Same as {@link #readTree(InputStream)} except content accessed through
2530
+ * passed-in {@link Reader}
2547
2531
*/
2548
2532
public JsonNode readTree (Reader r ) throws IOException {
2549
2533
return _readTreeAndClose (_jsonFactory .createParser (r ));
2550
2534
}
2551
2535
2552
2536
/**
2553
- * Method to deserialize JSON content as tree expressed using set of {@link JsonNode} instances.
2554
- * Returns root of the resulting tree (where root can consist of just a single node if the current
2555
- * event is a value event, not container).
2556
- *<p>
2557
- * If a low-level I/O problem (missing input, network error) occurs,
2558
- * a {@link IOException} will be thrown.
2559
- * If a parsing problem occurs (invalid JSON),
2560
- * {@link JsonParseException} will be thrown.
2561
- * If no content is found from input (end-of-input), Java
2562
- * <code>null</code> will be returned.
2563
- *
2564
- * @param content JSON content to parse to build the JSON tree.
2565
- *
2566
- * @return a {@link JsonNode}, if valid JSON content found; null
2567
- * if input has no content to bind -- note, however, that if
2568
- * JSON <code>null</code> token is found, it will be represented
2569
- * as a non-null {@link JsonNode} (one that returns <code>true</code>
2570
- * for {@link JsonNode#isNull()}
2571
- *
2572
- * @throws JsonParseException if underlying input contains invalid content
2573
- * of type {@link JsonParser} supports (JSON for default case)
2537
+ * Same as {@link #readTree(InputStream)} except content read from
2538
+ * passed-in {@link String}
2574
2539
*/
2575
2540
public JsonNode readTree (String content ) throws IOException {
2576
2541
return _readTreeAndClose (_jsonFactory .createParser (content ));
2577
2542
}
2578
2543
2579
2544
/**
2580
- * Method to deserialize JSON content as tree expressed using set of {@link JsonNode} instances.
2581
- * Returns root of the resulting tree (where root can consist of just a single node if the current
2582
- * event is a value event, not container).
2583
- *
2584
- * @param content JSON content to parse to build the JSON tree.
2585
- *
2586
- * @return a {@link JsonNode}, if valid JSON content found; null
2587
- * if input has no content to bind -- note, however, that if
2588
- * JSON <code>null</code> token is found, it will be represented
2589
- * as a non-null {@link JsonNode} (one that returns <code>true</code>
2590
- * for {@link JsonNode#isNull()}
2591
- *
2592
- * @throws JsonParseException if underlying input contains invalid content
2593
- * of type {@link JsonParser} supports (JSON for default case)
2545
+ * Same as {@link #readTree(InputStream)} except content read from
2546
+ * passed-in byte array.
2594
2547
*/
2595
2548
public JsonNode readTree (byte [] content ) throws IOException {
2596
2549
return _readTreeAndClose (_jsonFactory .createParser (content ));
2597
2550
}
2598
2551
2599
2552
/**
2600
- * @since 2.10
2553
+ * Same as {@link #readTree(InputStream)} except content read from
2554
+ * passed-in byte array.
2601
2555
*/
2602
2556
public JsonNode readTree (byte [] content , int offset , int len ) throws IOException {
2603
2557
return _readTreeAndClose (_jsonFactory .createParser (content , offset , len ));
2604
2558
}
2605
2559
2606
2560
/**
2607
- * Method to deserialize JSON content as tree expressed using set of {@link JsonNode} instances.
2608
- * Returns root of the resulting tree (where root can consist of just a single node if the current
2609
- * event is a value event, not container).
2610
- *
2611
- * @param file File of which contents to parse as JSON for building a tree instance
2612
- *
2613
- * @return a {@link JsonNode}, if valid JSON content found; null
2614
- * if input has no content to bind -- note, however, that if
2615
- * JSON <code>null</code> token is found, it will be represented
2616
- * as a non-null {@link JsonNode} (one that returns <code>true</code>
2617
- * for {@link JsonNode#isNull()}
2618
- *
2619
- * @throws IOException if a low-level I/O problem (unexpected end-of-input,
2620
- * network error) occurs (passed through as-is without additional wrapping -- note
2621
- * that this is one case where {@link DeserializationFeature#WRAP_EXCEPTIONS}
2622
- * does NOT result in wrapping of exception even if enabled)
2623
- * @throws JsonParseException if underlying input contains invalid content
2624
- * of type {@link JsonParser} supports (JSON for default case)
2561
+ * Same as {@link #readTree(InputStream)} except content read from
2562
+ * passed-in {@link File}.
2625
2563
*/
2626
2564
public JsonNode readTree (File file )
2627
2565
throws IOException , JsonProcessingException
@@ -2630,24 +2568,8 @@ public JsonNode readTree(File file)
2630
2568
}
2631
2569
2632
2570
/**
2633
- * Method to deserialize JSON content as tree expressed using set of {@link JsonNode} instances.
2634
- * Returns root of the resulting tree (where root can consist of just a single node if the current
2635
- * event is a value event, not container).
2636
- *
2637
- * @param source URL to use for fetching contents to parse as JSON for building a tree instance
2638
- *
2639
- * @return a {@link JsonNode}, if valid JSON content found; null
2640
- * if input has no content to bind -- note, however, that if
2641
- * JSON <code>null</code> token is found, it will be represented
2642
- * as a non-null {@link JsonNode} (one that returns <code>true</code>
2643
- * for {@link JsonNode#isNull()}
2644
- *
2645
- * @throws IOException if a low-level I/O problem (unexpected end-of-input,
2646
- * network error) occurs (passed through as-is without additional wrapping -- note
2647
- * that this is one case where {@link DeserializationFeature#WRAP_EXCEPTIONS}
2648
- * does NOT result in wrapping of exception even if enabled)
2649
- * @throws JsonParseException if underlying input contains invalid content
2650
- * of type {@link JsonParser} supports (JSON for default case)
2571
+ * Same as {@link #readTree(InputStream)} except content read from
2572
+ * passed-in {@link URL}.
2651
2573
*/
2652
2574
public JsonNode readTree (URL source ) throws IOException {
2653
2575
return _readTreeAndClose (_jsonFactory .createParser (source ));
0 commit comments