com.jayway.jsonpath.spi.json.JacksonJsonNodeJsonProvider Java Examples

The following examples show how to use com.jayway.jsonpath.spi.json.JacksonJsonNodeJsonProvider. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JsonUtils.java    From cs-actions with Apache License 2.0 5 votes vote down vote up
@NotNull
public static JsonContext getValidJsonContext(final String jsonObject) {
    try {
        final ObjectMapper objectMapper = new ObjectMapper().configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true);
        final AbstractJsonProvider provider = new JacksonJsonNodeJsonProvider(objectMapper);
        final Configuration configuration = Configuration.defaultConfiguration()
                .jsonProvider(provider);
        final JsonContext jsonContext = new JsonContext(configuration);
        jsonContext.parse(jsonObject);
        return jsonContext;
    } catch (IllegalArgumentException iae) {
        throw hammerIllegalArgumentExceptionWithMessage(INVALID_JSONOBJECT, iae);
    }
}