Class JsonReadingUtils

java.lang.Object
net.logstash.logback.composite.JsonReadingUtils

public class JsonReadingUtils extends Object
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 Details

    • readFully

      public static JsonNode readFully(JsonFactory jsonFactory, String json) throws IOException
      Fully read the supplied JSON string into the equivalent JsonNode. Throws a JsonParseException 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 value 10 leaving foobar unread.
      Parameters:
      jsonFactory - the JsonFactory from which to obtain a JsonParser to read the JSON string.
      json - the JSON string to read
      Returns:
      the JsonNode corresponding to the input string or null 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 an ObjectNode, throwing a JsonParseException if the supplied string is not a valid JSON object representation.
      Parameters:
      jsonFactory - the JsonFactory from which to obtain a JsonParser to read the JSON string.
      json - the JSON string to read
      Returns:
      the JsonNode corresponding to the input string or null if the string is null or empty.
      Throws:
      IOException - if there is either an underlying I/O problem or decoding issue
      See Also: