Search in sources :

Example 1 with JsonProvider

use of com.jayway.jsonpath.spi.json.JsonProvider in project JsonPath by jayway.

the class Append method invoke.

@Override
public Object invoke(String currentPath, PathRef parent, Object model, EvaluationContext ctx, List<Parameter> parameters) {
    JsonProvider jsonProvider = ctx.configuration().jsonProvider();
    if (parameters != null && parameters.size() > 0) {
        for (Parameter param : parameters) {
            if (jsonProvider.isArray(model)) {
                int len = jsonProvider.length(model);
                jsonProvider.setArrayIndex(model, len, param.getCachedValue());
            }
        }
    }
    return model;
}
Also used : Parameter(com.jayway.jsonpath.internal.function.Parameter) JsonProvider(com.jayway.jsonpath.spi.json.JsonProvider)

Example 2 with JsonProvider

use of com.jayway.jsonpath.spi.json.JsonProvider in project geode by apache.

the class UseJacksonForJsonPathRule method before.

/**
   * Override to set up your specific external resource.
   */
@Override
public void before() {
    saveDefaults();
    Configuration.setDefaults(new Defaults() {

        private final JsonProvider jsonProvider = new JacksonJsonProvider();

        private final MappingProvider mappingProvider = new JacksonMappingProvider();

        @Override
        public JsonProvider jsonProvider() {
            return jsonProvider;
        }

        @Override
        public MappingProvider mappingProvider() {
            return mappingProvider;
        }

        @Override
        public Set<Option> options() {
            return EnumSet.noneOf(Option.class);
        }
    });
}
Also used : JacksonMappingProvider(com.jayway.jsonpath.spi.mapper.JacksonMappingProvider) Defaults(com.jayway.jsonpath.Configuration.Defaults) Set(java.util.Set) EnumSet(java.util.EnumSet) JacksonJsonProvider(com.jayway.jsonpath.spi.json.JacksonJsonProvider) MappingProvider(com.jayway.jsonpath.spi.mapper.MappingProvider) JacksonMappingProvider(com.jayway.jsonpath.spi.mapper.JacksonMappingProvider) Option(com.jayway.jsonpath.Option) JacksonJsonProvider(com.jayway.jsonpath.spi.json.JacksonJsonProvider) JsonProvider(com.jayway.jsonpath.spi.json.JsonProvider)

Aggregations

JsonProvider (com.jayway.jsonpath.spi.json.JsonProvider)2 Defaults (com.jayway.jsonpath.Configuration.Defaults)1 Option (com.jayway.jsonpath.Option)1 Parameter (com.jayway.jsonpath.internal.function.Parameter)1 JacksonJsonProvider (com.jayway.jsonpath.spi.json.JacksonJsonProvider)1 JacksonMappingProvider (com.jayway.jsonpath.spi.mapper.JacksonMappingProvider)1 MappingProvider (com.jayway.jsonpath.spi.mapper.MappingProvider)1 EnumSet (java.util.EnumSet)1 Set (java.util.Set)1