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(ObjectMapper objectMapper, String json) Fully read the supplied JSON string into the equivalentJsonNode.static ObjectNodereadFullyAsObjectNode(ObjectMapper objectMapper, String json) Fully read a JSON string into anObjectNode, throwing aStreamReadExceptionif the supplied string is not a valid JSON object representation.
-
Method Details
-
readFully
Fully read the supplied JSON string into the equivalentJsonNode. Throws aStreamReadExceptionif 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:
objectMapper- theObjectMapperfrom 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.
-
readFullyAsObjectNode
Fully read a JSON string into anObjectNode, throwing aStreamReadExceptionif the supplied string is not a valid JSON object representation.- Parameters:
objectMapper- theObjectMapperfrom 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. - See Also:
-