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 JsonNodereadFully(JsonFactory jsonFactory, String json) Fully read the supplied JSON string into the equivalentJsonNode.static ObjectNodereadFullyAsObjectNode(JsonFactory jsonFactory, String json) Fully read a JSON string into anObjectNode, throwing aJsonParseExceptionif the supplied string is not a valid JSON object representation.
-
Method Details
-
readFully
Fully read the supplied JSON string into the equivalentJsonNode. Throws aJsonParseExceptionif 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 value10leaving foobar unread.- Parameters:
jsonFactory- theJsonFactoryfrom which to obtain aJsonParserto read the JSON string.json- the JSON string to read- Returns:
- the
JsonNodecorresponding to the input string ornullif 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 aJsonParseExceptionif the supplied string is not a valid JSON object representation.- Parameters:
jsonFactory- theJsonFactoryfrom which to obtain aJsonParserto read the JSON string.json- the JSON string to read- Returns:
- the
JsonNodecorresponding to the input string ornullif the string is null or empty. - Throws:
IOException- if there is either an underlying I/O problem or decoding issue- See Also:
-