Package org.frankframework.json
Class JsonUtil
java.lang.Object
org.frankframework.json.JsonUtil
-
Method Summary
Modifier and TypeMethodDescriptionstatic JsonMapper
buildJsonMapper
(IScopeProvider scopeProvider, String stylesheetName, DataSonnetOutputType outputType, boolean computeMimeType, ParameterList parameters) static com.jayway.jsonpath.JsonPath
compileJsonPath
(String jsonPathExpression) Compile aJsonPath
from thejsonPathExpression
parameter, if it's notnull
.static String
evaluateJsonPath
(com.jayway.jsonpath.JsonPath jsonPath, Object input) static String
evaluateJsonPathToSingleValue
(com.jayway.jsonpath.JsonPath jsonPath, Message message) static String
jsonPretty
(String json)
-
Method Details
-
buildJsonMapper
public static JsonMapper buildJsonMapper(IScopeProvider scopeProvider, String stylesheetName, DataSonnetOutputType outputType, boolean computeMimeType, ParameterList parameters) throws ConfigurationException - Throws:
ConfigurationException
-
compileJsonPath
@Nullable public static com.jayway.jsonpath.JsonPath compileJsonPath(@Nullable String jsonPathExpression) throws ConfigurationException Compile aJsonPath
from thejsonPathExpression
parameter, if it's notnull
. IfjsonPathExpression
isnull
, returnnull
.- Parameters:
jsonPathExpression
- JSON Path Expression to compile. May benull
.- Returns:
JsonPath
compiled from thejsonPathExpression
, ornull
ifjsonPathExpression
wasnull
.- Throws:
ConfigurationException
- If there was any exception in trying to compile thejsonPathExpression
, throw aConfigurationException
.
-
evaluateJsonPathToSingleValue
@Nullable public static String evaluateJsonPathToSingleValue(@Nonnull com.jayway.jsonpath.JsonPath jsonPath, Message message) throws JsonException Evaluate givenJsonPath
against the inputMessage
and return a single scalar value, represented asString
.
- If the expression evaluation results in a JsonArray, the first value of the array is returned.
- If the expression evaluation results in a JsonObject, an empty string is returned to indicate a non-scalar value was found.
- If the expression evaluation does not result in any value found, then
null
is returned to indicate that there was no result.
- Parameters:
jsonPath
-JsonPath
expression to evaluatemessage
-Message
from which to extract data- Returns:
- Single scalar value from the message, an empty string if the value could not be reduced to a scalar, or
null
if there was no result. - Throws:
JsonException
- If an exception occurred evaluating the expression aJsonException
is thrown.
-
evaluateJsonPath
@Nonnull public static String evaluateJsonPath(@Nonnull com.jayway.jsonpath.JsonPath jsonPath, @Nonnull Object input) throws JsonException - Throws:
JsonException
-
jsonPretty
-