当前位置: 首页>>代码示例>>Java>>正文


Java Option类代码示例

本文整理汇总了Java中com.jayway.jsonpath.Option的典型用法代码示例。如果您正苦于以下问题:Java Option类的具体用法?Java Option怎么用?Java Option使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Option类属于com.jayway.jsonpath包,在下文中一共展示了Option类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: before

import com.jayway.jsonpath.Option; //导入依赖的package包/类
/**
 * 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);
    }

  });
}
 
开发者ID:ampool,项目名称:monarch,代码行数:29,代码来源:UseJacksonForJsonPathRule.java

示例2: restoreDefaults

import com.jayway.jsonpath.Option; //导入依赖的package包/类
private void restoreDefaults() {
  if (!this.hadDefaults) {
    return;
  }
  Configuration.setDefaults(new Defaults() {

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

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

    @Override
    public Set<Option> options() {
      return options;
    }

  });
}
 
开发者ID:ampool,项目名称:monarch,代码行数:24,代码来源:UseJacksonForJsonPathRule.java

示例3: init

import com.jayway.jsonpath.Option; //导入依赖的package包/类
@SuppressWarnings("WeakerAccess")
public void init(){
    // jsonpath配置初始化
    com.jayway.jsonpath.Configuration.setDefaults(new com.jayway.jsonpath.Configuration.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);
        }
    });
}
 
开发者ID:QianmiOpen,项目名称:interface-test,代码行数:25,代码来源:InterfaceTestApplication.java

示例4: setUp

import com.jayway.jsonpath.Option; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    com.jayway.jsonpath.Configuration.setDefaults(new com.jayway.jsonpath.Configuration.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);
        }
    });
}
 
开发者ID:QianmiOpen,项目名称:interface-test,代码行数:23,代码来源:TestCaseLoaderTest.java

示例5: setDefaults

import com.jayway.jsonpath.Option; //导入依赖的package包/类
public static void setDefaults() {
    Configuration.setDefaults(new Configuration.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);
        }
    });
}
 
开发者ID:revinate,项目名称:assertj-json,代码行数:22,代码来源:TestConfig.java

示例6: evaluate

import com.jayway.jsonpath.Option; //导入依赖的package包/类
@Override
public void evaluate(String currentPath, PathRef parent, Object model, EvaluationContextImpl ctx) {
    if (ctx.jsonProvider().isMap(model)) {
        for (String property : ctx.jsonProvider().getPropertyKeys(model)) {
            handleObjectProperty(currentPath, model, ctx, asList(property));
        }
    } else if (ctx.jsonProvider().isArray(model)) {
        for (int idx = 0; idx < ctx.jsonProvider().length(model); idx++) {
            try {
                handleArrayIndex(idx, currentPath, model, ctx);
            } catch (PathNotFoundException p){
                if(ctx.options().contains(Option.REQUIRE_PROPERTIES)){
                    throw p;
                }
            }
        }
    }
}
 
开发者ID:osswangxining,项目名称:another-rule-based-analytics-on-spark,代码行数:19,代码来源:WildcardPathToken.java

示例7: SelectJsonPath

import com.jayway.jsonpath.Option; //导入依赖的package包/类
@Inject
public SelectJsonPath(ObjectMapper objectMapper) {
    configuration = Configuration.builder()
            .options(Option.SUPPRESS_EXCEPTIONS)
            .jsonProvider(new JacksonJsonNodeJsonProvider(objectMapper))
            .build();

    jsonParam = ParameterDescriptor.type("json", JsonNode.class).description("A parsed JSON tree").build();
    // sigh generics and type erasure
    //noinspection unchecked
    pathsParam = ParameterDescriptor.type("paths",
                                          (Class<Map<String, String>>) new TypeLiteral<Map<String, String>>() {}.getRawType(),
                                          (Class<Map<String, JsonPath>>) new TypeLiteral<Map<String, JsonPath>>() {}.getRawType())
            .transform(inputMap -> inputMap
                    .entrySet().stream()
                    .collect(toMap(Map.Entry::getKey, e -> JsonPath.compile(e.getValue()))))
            .description("A map of names to a JsonPath expression, see http://jsonpath.com")
            .build();
}
 
开发者ID:Graylog2,项目名称:graylog-plugin-pipeline-processor,代码行数:20,代码来源:SelectJsonPath.java

示例8: afterPropertiesSet

import com.jayway.jsonpath.Option; //导入依赖的package包/类
@Override
public void afterPropertiesSet() throws Exception {
    
    Configuration.setDefaults(new Configuration.Defaults() {

        private final JsonProvider jsonProvider = new JacksonJsonProvider();
        
        @Override
        public JsonProvider jsonProvider() {
            return jsonProvider;
        }

        @Override
        public Set<Option> options() {
            return EnumSet.noneOf(Option.class);
        }

        @Override
        public MappingProvider mappingProvider() {
            return new JacksonMappingProvider();
        }
    });
    
}
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:25,代码来源:JSONProfileServiceImpl.java

示例9: createExpression

import com.jayway.jsonpath.Option; //导入依赖的package包/类
@Override
public Expression createExpression(CamelContext camelContext, Annotation annotation,
                                   LanguageAnnotation languageAnnotation, Class<?> expressionReturnType) {

    String expression = getExpressionFromAnnotation(annotation);
    JsonPathExpression answer = new JsonPathExpression(expression);

    if (expressionReturnType != null) {
        answer.setResultType(expressionReturnType);
    }

    if (annotation instanceof JsonPath) {
        JsonPath jsonPathAnnotation = (JsonPath) annotation;

        answer.setSuppressExceptions(jsonPathAnnotation.suppressExceptions());

        Option[] options = jsonPathAnnotation.options();
        answer.setOptions(options);
    }

    answer.init();
    return answer;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:24,代码来源:JsonPathAnnotationExpressionFactory.java

示例10: save

import com.jayway.jsonpath.Option; //导入依赖的package包/类
public void save(@NotNull SchemaFormContentAware newEntity, SchemaFormContentAware oldEntity, String entityPath) {
  Assert.notNull(newEntity, "New content cannot be null");

  Object json = defaultConfiguration().jsonProvider().parse(newEntity.getContent());
  DocumentContext newContext = JsonPath.using(defaultConfiguration().addOptions(Option.AS_PATH_LIST)).parse(json);
  Map<String, JSONArray> newPaths = getPathFilesMap(newContext, json);
  if (newPaths == null) return; // content does not have any file field

  if (oldEntity != null) {
    Object oldJson = defaultConfiguration().jsonProvider().parse(oldEntity.getContent());
    DocumentContext oldContext = JsonPath.using(defaultConfiguration().addOptions(Option.AS_PATH_LIST)).parse(oldJson);
    Map<String, JSONArray> oldPaths = getPathFilesMap(oldContext, oldJson);
    if (oldPaths != null) {
      saveAndDelete(oldPaths, newPaths, entityPath);
    } else {
      // schema and definition now have files
      newPaths.values().forEach(v -> saveFiles(v, entityPath));
    }

  } else {
    newPaths.values().forEach(v -> saveFiles(v, entityPath));
  }

  cleanup(newPaths, newContext);
  newEntity.setContent(newContext.jsonString());
}
 
开发者ID:obiba,项目名称:mica2,代码行数:27,代码来源:SchemaFormContentFileService.java

示例11: test

import com.jayway.jsonpath.Option; //导入依赖的package包/类
@Test
    public void test() throws ScriptException {
        com.jayway.jsonpath.Configuration.setDefaults(new com.jayway.jsonpath.Configuration.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);
            }
        });
//        DocumentContext doc = JsonPath.parse(this.getClass().getClassLoader().getResourceAsStream("nashorn.js")); //InvalidJsonException
//        TestSuit testSuit = doc.read("$", TestSuit.class);

        ScriptEngineManager scriptEngineManager = new ScriptEngineManager();
        ScriptEngine nashorn = scriptEngineManager.getEngineByName("nashorn");

        nashorn.eval(new InputStreamReader(this.getClass().getClassLoader().getResourceAsStream("nashorn.js")));//ScriptException->ParserException

        Object obj = nashorn.eval("JSON.stringify(testSuit)");

        System.out.println(obj);


    }
 
开发者ID:QianmiOpen,项目名称:interface-test,代码行数:37,代码来源:NashornTest.java

示例12: replace

import com.jayway.jsonpath.Option; //导入依赖的package包/类
public Map<String, Object> replace(Map<String, Object> input, Object json) {
	Object doc = null;
	if(json instanceof String) {
		doc = JsonPath.parse(json.toString());
	} else {
		doc = json;
	}
	Configuration option = Configuration.defaultConfiguration().addOptions(Option.SUPPRESS_EXCEPTIONS);
	DocumentContext io = JsonPath.parse(doc, option);
	return replace(input, io, null);
}
 
开发者ID:Netflix,项目名称:conductor,代码行数:12,代码来源:ParametersUtils.java

示例13: set

import com.jayway.jsonpath.Option; //导入依赖的package包/类
@Override
public DocumentContext set(JsonPath path, Object newValue){
    List<String> modified = path.set(json, newValue, configuration.addOptions(Option.AS_PATH_LIST));
    if(logger.isDebugEnabled()){
        for (String p : modified) {
            logger.debug("Set path {} new value {}", p, newValue);
        }
    }
    return this;
}
 
开发者ID:osswangxining,项目名称:another-rule-based-analytics-on-spark,代码行数:11,代码来源:JsonContext.java

示例14: delete

import com.jayway.jsonpath.Option; //导入依赖的package包/类
@Override
public DocumentContext delete(JsonPath path) {
    List<String> modified = path.delete(json, configuration.addOptions(Option.AS_PATH_LIST));
    if(logger.isDebugEnabled()){
        for (String p : modified) {
            logger.debug("Delete path {}");
        }
    }
    return this;
}
 
开发者ID:osswangxining,项目名称:another-rule-based-analytics-on-spark,代码行数:11,代码来源:JsonContext.java

示例15: add

import com.jayway.jsonpath.Option; //导入依赖的package包/类
@Override
public DocumentContext add(JsonPath path, Object value){
    List<String> modified =  path.add(json, value, configuration.addOptions(Option.AS_PATH_LIST));
    if(logger.isDebugEnabled()){
        for (String p : modified) {
            logger.debug("Add path {} new value {}", p, value);
        }
    }
    return this;
}
 
开发者ID:osswangxining,项目名称:another-rule-based-analytics-on-spark,代码行数:11,代码来源:JsonContext.java


注:本文中的com.jayway.jsonpath.Option类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。