Package com.realobjects.pdfreactor.util
Class JsonUtil
java.lang.Object
com.realobjects.pdfreactor.util.JsonUtil
This class provides methods to convert a JSON string into a Configuration
instance
and to serialize a Configuration
instance into JSON.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Configuration
parseConfig
(boolean lenient, InputStream... inputStreams) Parses a PDFreactor configuration into JSON format.static Configuration
parseConfig
(boolean lenient, String... inputs) Parses a PDFreactor configuration into JSON format.static Configuration
parseConfig
(InputStream... inputStreams) Parses a PDFreactor configuration into JSON format.static Configuration
parseConfig
(String... inputs) Parses a PDFreactor configuration into JSON format.static String
serializeConfig
(Configuration config) Serializes a PDFreactorConfiguration
instance into a JSON representation.
-
Constructor Details
-
JsonUtil
public JsonUtil()
-
-
Method Details
-
parseConfig
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
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
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
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 identicalConfiguration
.- Parameters:
config
- TheConfiguration
instance.- Returns:
- A JSON string.
- Throws:
IOException
- if theConfiguration
could not be serialized.MissingDependencyException
- if required dependencies are not available
-