Package net.logstash.logback.composite
Class JsonReadingUtils
java.lang.Object
net.logstash.logback.composite.JsonReadingUtils
Utilities for reading/parsing JSON string.
Note: This class is for internal use only and subject to backward incompatible change at any time.
- Author:
- brenuart
-
Method Summary
Modifier and TypeMethodDescriptionstatic JsonNode
readFully
(JsonFactory jsonFactory, String json) Fully read the supplied JSON string into the equivalentJsonNode
.static ObjectNode
readFullyAsObjectNode
(JsonFactory jsonFactory, String json) Fully read a JSON string into anObjectNode
, throwing aJsonParseException
if the supplied string is not a valid JSON object representation.
-
Method Details
-
readFully
Fully read the supplied JSON string into the equivalentJsonNode
. Throws aJsonParseException
if the string is not fully read after a first valid JsonNode is found. This may happen for input like 10 foobar that would otherwise return a NumericNode with value10
leaving foobar unread.- Parameters:
jsonFactory
- theJsonFactory
from which to obtain aJsonParser
to read the JSON string.json
- the JSON string to read- Returns:
- the
JsonNode
corresponding to the input string ornull
if the string is null or empty. - Throws:
IOException
- if there is either an underlying I/O problem or decoding issue
-
readFullyAsObjectNode
public static ObjectNode readFullyAsObjectNode(JsonFactory jsonFactory, String json) throws IOException Fully read a JSON string into anObjectNode
, throwing aJsonParseException
if the supplied string is not a valid JSON object representation.- Parameters:
jsonFactory
- theJsonFactory
from which to obtain aJsonParser
to read the JSON string.json
- the JSON string to read- Returns:
- the
JsonNode
corresponding to the input string ornull
if the string is null or empty. - Throws:
IOException
- if there is either an underlying I/O problem or decoding issue- See Also:
-