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


Java JsonProvider类代码示例

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


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

示例1: before

import com.jayway.jsonpath.spi.json.JsonProvider; //导入依赖的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.spi.json.JsonProvider; //导入依赖的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.spi.json.JsonProvider; //导入依赖的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.spi.json.JsonProvider; //导入依赖的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.spi.json.JsonProvider; //导入依赖的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: afterPropertiesSet

import com.jayway.jsonpath.spi.json.JsonProvider; //导入依赖的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

示例7: hello

import com.jayway.jsonpath.spi.json.JsonProvider; //导入依赖的package包/类
@Test
public void hello() throws URISyntaxException, IOException {
	JsonProvider jsonProvider = Configuration.defaultConfiguration().jsonProvider();
	String recordId = "2022320/3F61C612ED9C42CCB85E533B4736795E8BDC7E77";
	String jsonString = readContent("general/td-idf-response.json");
	assertEquals("{", jsonString.substring(0,1));

	TfIdfExtractor extractor = new TfIdfExtractor(new EdmOaiPmhXmlSchema());
	FieldCounter<Double> results = extractor.extract(jsonString, recordId);
	assertEquals(6, results.size());
	assertEquals(new Double(0.0017653998874690505), results.get("dc:title:avg"));
	assertEquals(new Double(0.008826999437345252), results.get("dc:title:sum"));
	assertEquals(new Double(0), results.get("dcterms:alternative:avg"));
	assertEquals(new Double(0), results.get("dcterms:alternative:sum"));
	assertEquals(new Double(0), results.get("dc:description:avg"));
	assertEquals(new Double(0), results.get("dc:description:sum"));
}
 
开发者ID:pkiraly,项目名称:metadata-qa-api,代码行数:18,代码来源:TfIdfExtractorTest.java

示例8: Configuration

import com.jayway.jsonpath.spi.json.JsonProvider; //导入依赖的package包/类
private Configuration(JsonProvider jsonProvider, MappingProvider mappingProvider, EnumSet<Option> options, Collection<EvaluationListener> evaluationListeners) {
    notNull(jsonProvider, "jsonProvider can not be null");
    notNull(mappingProvider, "mappingProvider can not be null");
    notNull(options, "setOptions can not be null");
    notNull(evaluationListeners, "evaluationListeners can not be null");
    this.jsonProvider = jsonProvider;
    this.mappingProvider = mappingProvider;
    this.options = Collections.unmodifiableSet(options);
    this.evaluationListeners = Collections.unmodifiableCollection(evaluationListeners);
}
 
开发者ID:osswangxining,项目名称:iot-edge-greengrass,代码行数:11,代码来源:Configuration.java

示例9: test

import com.jayway.jsonpath.spi.json.JsonProvider; //导入依赖的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

示例10: renameInMap

import com.jayway.jsonpath.spi.json.JsonProvider; //导入依赖的package包/类
protected void renameInMap(Object targetMap, String oldKeyName, String newKeyName, Configuration configuration){
    if(configuration.jsonProvider().isMap(targetMap)){
        if(configuration.jsonProvider().getMapValue(targetMap, oldKeyName) == JsonProvider.UNDEFINED){
            throw new PathNotFoundException("No results for Key "+oldKeyName+" found in map!");
        }
        configuration.jsonProvider().setProperty(targetMap, newKeyName, configuration.jsonProvider().getMapValue(targetMap, oldKeyName));
        configuration.jsonProvider().removeProperty(targetMap, oldKeyName);
    } else {
        throw new InvalidModificationException("Can only rename properties in a map");
    }
}
 
开发者ID:osswangxining,项目名称:another-rule-based-analytics-on-spark,代码行数:12,代码来源:PathRef.java

示例11: invoke

import com.jayway.jsonpath.spi.json.JsonProvider; //导入依赖的package包/类
@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.getValue());
            }
        }
    }
    return model;
}
 
开发者ID:osswangxining,项目名称:another-rule-based-analytics-on-spark,代码行数:14,代码来源:Append.java

示例12: walkObject

import com.jayway.jsonpath.spi.json.JsonProvider; //导入依赖的package包/类
public static void walkObject(PathToken pt, String currentPath, PathRef parent, Object model, EvaluationContextImpl ctx, Predicate predicate) {

        if (predicate.matches(model)) {
            pt.evaluate(currentPath, parent, model, ctx);
        }
        Collection<String> properties = ctx.jsonProvider().getPropertyKeys(model);

        for (String property : properties) {
            String evalPath = currentPath + "['" + property + "']";
            Object propertyModel = ctx.jsonProvider().getMapValue(model, property);
            if (propertyModel != JsonProvider.UNDEFINED) {
                walk(pt, evalPath, PathRef.create(model, property), propertyModel, ctx, predicate);
            }
        }
    }
 
开发者ID:osswangxining,项目名称:another-rule-based-analytics-on-spark,代码行数:16,代码来源:ScanPathToken.java

示例13: initialize

import com.jayway.jsonpath.spi.json.JsonProvider; //导入依赖的package包/类
@Override
public void initialize(Bootstrap<IronTestConfiguration> bootstrap) {
    bootstrap.addBundle(new AssetsBundle("/assets/app", "/ui", "index.htm", "ui"));
    bootstrap.addBundle(new AssetsBundle("/META-INF/resources/webjars", "/ui/lib", null, "uilib"));
    bootstrap.addBundle(jaxWsBundle);
    bootstrap.addBundle(new MultiPartBundle());
    bootstrap.addBundle(new ViewBundle<IronTestConfiguration>(){
        @Override
        public Map<String, Map<String, String>> getViewConfiguration(IronTestConfiguration config) {
            return config.getViewRendererConfiguration();
        }
    });
    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:zheng-wang,项目名称:irontest,代码行数:33,代码来源:IronTestApplication.java

示例14: init

import com.jayway.jsonpath.spi.json.JsonProvider; //导入依赖的package包/类
@Override
public Instance<String> init(BlobMetadata data, Payload payload, boolean isSegment) {

	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.of(Option.ALWAYS_RETURN_LIST);
		}
	});

	DocumentContext context;
	try {
		context = JsonPath.parse(payload.openStream());
	} catch (IOException e) {
		payload.release();
		throw Throwables.propagate(e);
	}
	return new JsonSelectorInstance(context);
}
 
开发者ID:Treydone,项目名称:mandrel,代码行数:34,代码来源:JsonSelector.java

示例15: configure

import com.jayway.jsonpath.spi.json.JsonProvider; //导入依赖的package包/类
/**
 * UnRAVL can be configured with Spring by loading the Spring config
 * classpath:/META-INF/spring/unravlApplicationContext.xml . If that has not
 * been done, this method initializes Spring. Spring performs a
 * component-scan for assertions, body generators, and extractors. As each
 * such component is loaded, it's runtime property is {@literal @} autowired
 * to a UnRAVLRuntime instance this calls the register*() methods. See
 * {@link UnRAVLRequestBodyGenerator}, {@link UnRAVLAssertionPlugin}, and
 * {@link UnRAVLExtractorPlugin}.
 */
public static synchronized void configure() {
    if (ctx != null)
        return;

    // Configure Spring. Works on Unix; fails on Windows?
    String[] contextXml = new String[] { "/META-INF/spring/unravlApplicationContext.xml" };
    ctx = new ClassPathXmlApplicationContext(contextXml);
    assert (ctx != null);

    // Configure jsonPath to use Jackson
    Configuration.Defaults jsonPathConfig = 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);
        }
    };

    Configuration.setDefaults(jsonPathConfig);
}
 
开发者ID:sassoftware,项目名称:unravl,代码行数:44,代码来源:UnRAVLRuntime.java


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