Class JsonUtil

java.lang.Object
com.realobjects.pdfreactor.util.JsonUtil

public class JsonUtil extends Object

This class provides methods to convert a JSON string into a Configuration instance and to serialize a Configuration instance into JSON.

  • Constructor Details

    • JsonUtil

      public JsonUtil()
  • Method Details

    • parseConfig

      public static Configuration parseConfig(InputStream... inputStreams) throws IOException

      Parses a PDFreactor configuration into JSON format.

      Parameters:
      inputStreams - The JSON strings which will be merged.
      Returns:
      A Configuration instance.
      Throws:
      IOException - if the JSON string could not be parsed.
      MissingDependencyException - if required dependencies are not available
    • parseConfig

      public static Configuration parseConfig(boolean lenient, InputStream... inputStreams) throws IOException

      Parses a PDFreactor configuration into JSON format.

      Parameters:
      lenient - Whether to be lenient when parsing a config, i.e. ignoring unknown properties and converting empty types into null.
      inputStreams - The JSON strings which will be merged.
      Returns:
      A Configuration instance.
      Throws:
      IOException - if the JSON string could not be parsed.
      MissingDependencyException - if required dependencies are not available
    • parseConfig

      public static Configuration parseConfig(String... inputs) throws IOException

      Parses a PDFreactor configuration into JSON format.

      Parameters:
      inputs - The JSON strings which will be merged.
      Returns:
      A Configuration instance.
      Throws:
      IOException - if the JSON string could not be parsed.
      MissingDependencyException - if required dependencies are not available
    • parseConfig

      public static Configuration parseConfig(boolean lenient, String... inputs) throws IOException

      Parses a PDFreactor configuration into JSON format.

      Parameters:
      lenient - Whether to be lenient when parsing a config, i.e. ignoring unknown properties and converting empty types into null.
      inputs - The JSON strings which will be merged.
      Returns:
      A Configuration instance.
      Throws:
      IOException - if the JSON string could not be parsed.
      MissingDependencyException - if required dependencies are not available
    • serializeConfig

      public static String serializeConfig(Configuration config) throws IOException

      Serializes a PDFreactor Configuration instance into a JSON representation.

      Note that the JSON is not an exact representation of the configuration as it truncates some data types and property values for readability purposes. This means parsing the resulting JSON with parseConfig(InputStream...) may not produce an identical Configuration.

      Parameters:
      config - The Configuration instance.
      Returns:
      A JSON string.
      Throws:
      IOException - if the Configuration could not be serialized.
      MissingDependencyException - if required dependencies are not available