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


Java YAMLMapper类代码示例

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


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

示例1: deserializeFromIndexFiles

import com.fasterxml.jackson.dataformat.yaml.YAMLMapper; //导入依赖的package包/类
protected List<PackageMetadata> deserializeFromIndexFiles(List<File> indexFiles) {
	List<PackageMetadata> packageMetadataList = new ArrayList<>();
	YAMLMapper yamlMapper = new YAMLMapper();
	yamlMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
	for (File indexFile : indexFiles) {
		try {
			MappingIterator<PackageMetadata> it = yamlMapper.readerFor(PackageMetadata.class).readValues(indexFile);
			while (it.hasNextValue()) {
				PackageMetadata packageMetadata = it.next();
				packageMetadataList.add(packageMetadata);
			}
		}
		catch (IOException e) {
			throw new IllegalArgumentException("Can't parse Release manifest YAML", e);
		}
	}
	return packageMetadataList;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-skipper,代码行数:19,代码来源:PackageMetadataService.java

示例2: test

import com.fasterxml.jackson.dataformat.yaml.YAMLMapper; //导入依赖的package包/类
@Test
public void test() throws JsonProcessingException, IOException {
	Object parsedYaml = new Yaml().load(modelUrl.openStream());
	JsonNode tree = new YAMLMapper().convertValue(parsedYaml, JsonNode.class);
	final OpenApi3 model = (OpenApi3) new OpenApiParser().parse(modelUrl, false);
	Predicate<JsonNode> valueNodePredicate = n -> n.isValueNode();

	JsonTreeWalker.WalkMethod valueChecker = new JsonTreeWalker.WalkMethod() {
		@Override
		public void run(JsonNode node, JsonPointer path) {
			IJsonOverlay<?> overlay = ((OpenApi3Impl) model).find(path);
			assertNotNull("No overlay object found for path: " + path, overlay);
			Object fromJson = getValue(node);
			String msg = String.format("Wrong overlay value for path '%s': expected '%s', got '%s'", path, fromJson,
					overlay.get());
			assertEquals(msg, fromJson, overlay.get());
		}
	};
	JsonTreeWalker.walkTree(tree, valueNodePredicate, valueChecker);
}
 
开发者ID:networknt,项目名称:openapi-parser,代码行数:21,代码来源:BigParseTest.java

示例3: writeYamlConfigToFile

import com.fasterxml.jackson.dataformat.yaml.YAMLMapper; //导入依赖的package包/类
@Test
public void writeYamlConfigToFile() throws Exception {
  Map<String, String> configuration = createDummyConfiguration();

  File destPath = Files.createTempFile("config", "yaml").toFile();
  destPath.deleteOnExit();

  writer.writeConfigToFile(ConfigFileType.YAML, configuration, destPath);
  assertTrue(destPath.exists());
  try (InputStream is = new FileInputStream(destPath)) {
    String content = IOUtils.toString(is);
    System.out.println("Test print: yaml content - " + content);

    ObjectMapper mapper = new YAMLMapper();
    Map<String, Object> readConfig = mapper.readValue(content, Map.class);

    assertEquals(configuration, readConfig);
  }
}
 
开发者ID:hortonworks,项目名称:streamline,代码行数:20,代码来源:ConfigFileWriterTest.java

示例4: YamlJackson2HttpMessageConverter

import com.fasterxml.jackson.dataformat.yaml.YAMLMapper; //导入依赖的package包/类
YamlJackson2HttpMessageConverter() {
	super(new YAMLMapper().enable(Feature.MINIMIZE_QUOTES), MediaType.parseMediaType("application/x-yaml"));
	this.getObjectMapper().configure(JsonGenerator.Feature.QUOTE_FIELD_NAMES, false);
	this.getObjectMapper().configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
	this.getObjectMapper().enable(SerializationFeature.INDENT_OUTPUT);
	this.getObjectMapper().setSerializationInclusion(Include.NON_NULL);
}
 
开发者ID:damianwajser,项目名称:spring-rest-commons-options,代码行数:8,代码来源:WebMvcConfiguration.java

示例5: YamlJackson

import com.fasterxml.jackson.dataformat.yaml.YAMLMapper; //导入依赖的package包/类
public YamlJackson() {
	super(new YAMLMapper());
	
	// Install MongoDB / BSON serializers
	// (Using JSON serializers)
	tryToAddSerializers("io.datatree.dom.adapters.JsonJacksonBsonSerializers", mapper, prettyMapper);
}
 
开发者ID:berkesa,项目名称:datatree-adapters,代码行数:8,代码来源:YamlJackson.java

示例6: robotInit

import com.fasterxml.jackson.dataformat.yaml.YAMLMapper; //导入依赖的package包/类
/**
 * The method that runs when the robot is turned on. Initializes all subsystems from the map.
 */
public void robotInit() {
	//Set up start time
	Clock.setStartTime();
	Clock.updateTime();

	enabled = false;

	//Yes this should be a print statement, it's useful to know that robotInit started.
	System.out.println("Started robotInit.");
	Yaml yaml = new Yaml();
	try {
		Map<?, ?> normalized = (Map<?, ?>) yaml.load(new FileReader(RESOURCES_PATH+"ballbasaur_map.yml"));
		YAMLMapper mapper = new YAMLMapper();
		String fixed = mapper.writeValueAsString(normalized);
		mapper.registerModule(new ParameterNamesModule(JsonCreator.Mode.PROPERTIES));
		robotMap = mapper.readValue(fixed, RobotMap.class);
	} catch (IOException e) {
		System.out.println("Config file is bad/nonexistent!");
		e.printStackTrace();
	}

	//Read sensors
	this.robotMap.getUpdater().run();

	this.loggerNotifier = new Notifier(robotMap.getLogger());
	this.driveSubsystem = robotMap.getDrive();

	//Run the logger to write all the events that happened during initialization to a file.
	robotMap.getLogger().run();
	Clock.updateTime();
}
 
开发者ID:PB020,项目名称:Ballbasaur-Code-Rewrite,代码行数:35,代码来源:Robot.java

示例7: fromYamlFile

import com.fasterxml.jackson.dataformat.yaml.YAMLMapper; //导入依赖的package包/类
/**
 * Parses metadata about the match from the given file.
 * @param path the filename.
 * @return the metadata about the match.
 * @throws IOException when metadata cannot be read.
 */
public static Match fromYamlFile(Path path) throws IOException {
  final YAMLMapper mapper = new MatchMetadataYamlMapper();
  Match metadata;
  try (Reader rd = Files.newBufferedReader(path, Charset.defaultCharset())) {
    metadata = mapper.readValue(rd, Match.class);
  }
  return metadata;
}
 
开发者ID:braineering,项目名称:socstream,代码行数:15,代码来源:MatchService.java

示例8: commandLineRunner

import com.fasterxml.jackson.dataformat.yaml.YAMLMapper; //导入依赖的package包/类
@Bean
@Profile("cli")
public CommandLineRunner commandLineRunner(ReadinessClient readinessClient) {
    return args -> {
        ReadinessResponse readiness = readinessClient.getReadiness();
        log.info(new YAMLMapper().writeValueAsString(ImmutableMap.of("readiness", readiness)));
    };
}
 
开发者ID:ePages-de,项目名称:spring-boot-readiness,代码行数:9,代码来源:ReadinessApplication.java

示例9: robotInit

import com.fasterxml.jackson.dataformat.yaml.YAMLMapper; //导入依赖的package包/类
/**
 * The method that runs when the robot is turned on. Initializes all subsystems from the map.
 */
public void robotInit() {
    //Set up start time
    Clock.setStartTime();
    Clock.updateTime();

    enabled = false;

    //Yes this should be a print statement, it's useful to know that robotInit started.
    System.out.println("Started robotInit.");

    Yaml yaml = new Yaml();
    try {
        //Read the yaml file with SnakeYaml so we can use anchors and merge syntax.
        Map<?, ?> normalized = (Map<?, ?>) yaml.load(new FileReader(RESOURCES_PATH + mapName));
        YAMLMapper mapper = new YAMLMapper();
        //Turn the Map read by SnakeYaml into a String so Jackson can read it.
        String fixed = mapper.writeValueAsString(normalized);
        //Use a parameter name module so we don't have to specify name for every field.
        mapper.registerModule(new ParameterNamesModule(JsonCreator.Mode.PROPERTIES));
        //Add mix-ins
        mapper.registerModule(new WPIModule());
        //Deserialize the map into an object.
        robotMap = mapper.readValue(fixed, RobotMap.class);
    } catch (IOException e) {
        //This is either the map file not being in the file system OR it being improperly formatted.
        System.out.println("Config file is bad/nonexistent!");
        e.printStackTrace();
    }

    //Read sensors
    this.robotMap.getUpdater().run();

    //Set fields from the map.
    this.loggerNotifier = new Notifier(robotMap.getLogger());

    //Run the logger to write all the events that happened during initialization to a file.
    robotMap.getLogger().run();
    Clock.updateTime();
}
 
开发者ID:blair-robot-project,项目名称:449-central-repo,代码行数:43,代码来源:Robot.java

示例10: AuditTrailLogService

import com.fasterxml.jackson.dataformat.yaml.YAMLMapper; //导入依赖的package包/类
@Autowired
public AuditTrailLogService(final RestOperations instanceLogsRestOperations,
                            final AuditTrailProperties properties, ObjectMapper objectMapper,
                            final YAMLMapper yamlMapper) {

    this.restOperations = instanceLogsRestOperations;
    this.properties = properties;
    this.objectMapper = objectMapper;
    this.yamlMapper = yamlMapper;
}
 
开发者ID:zalando-stups,项目名称:log-sink,代码行数:11,代码来源:AuditTrailLogService.java

示例11: setup

import com.fasterxml.jackson.dataformat.yaml.YAMLMapper; //导入依赖的package包/类
@Before
public void setup() throws Exception
{
	YAMLMapper mapper = new YAMLMapper();
	ClassPathResource resource = new ClassPathResource("fixtures/declaration.yml");
	fixture = mapper.readValue(resource.getFile(), Declaration.class);

	CloudFoundryFacade cf = mock(CloudFoundryFacade.class);
	UaaFacade uaa = mock(UaaFacade.class);

	handlerFactory = new HandlerConfig().handlerFactory(cf, uaa);
	builder = new HardcodedOrderedHandlerBuilder(handlerFactory);
}
 
开发者ID:EngineerBetter,项目名称:cf-converger,代码行数:14,代码来源:HardcodedOrderedIntentBuilderTest.java

示例12: unmarshallsCorrectly

import com.fasterxml.jackson.dataformat.yaml.YAMLMapper; //导入依赖的package包/类
@Test
public void unmarshallsCorrectly() throws Exception
{
	ClassPathResource resource = new ClassPathResource("fixtures/declaration.yml");
	YAMLMapper mapper = new YAMLMapper();
	Declaration declaration = mapper.readValue(resource.getFile(), Declaration.class);

	assertThat(declaration.schemaVersion, is(2));
	assertThat(declaration.org.name, is("my-lovely-org"));
}
 
开发者ID:EngineerBetter,项目名称:cf-converger,代码行数:11,代码来源:YamlUnmarshallingTest.java

示例13: printEventsYaml

import com.fasterxml.jackson.dataformat.yaml.YAMLMapper; //导入依赖的package包/类
public void printEventsYaml(OutputStream out) throws IOException {
	YAMLFactory yf = new YAMLFactory();
	YAMLMapper mapper = new YAMLMapper();
	ObjectNode root = mapper.createObjectNode();
	for (Event event : events) {
		root.put(event.getId().get(), event.getInstruction().get());
	}
	yf.createGenerator(out).setCodec(mapper).writeObject(root);
}
 
开发者ID:Co0sh,项目名称:BetonQuest-Editor,代码行数:10,代码来源:QuestPackage.java

示例14: printConditionsYaml

import com.fasterxml.jackson.dataformat.yaml.YAMLMapper; //导入依赖的package包/类
public void printConditionsYaml(OutputStream out) throws IOException {
	YAMLFactory yf = new YAMLFactory();
	YAMLMapper mapper = new YAMLMapper();
	ObjectNode root = mapper.createObjectNode();
	for (Condition condition : conditions) {
		root.put(condition.getId().get(), condition.getInstruction().get());
	}
	yf.createGenerator(out).setCodec(mapper).writeObject(root);
}
 
开发者ID:Co0sh,项目名称:BetonQuest-Editor,代码行数:10,代码来源:QuestPackage.java

示例15: printObjectivesYaml

import com.fasterxml.jackson.dataformat.yaml.YAMLMapper; //导入依赖的package包/类
public void printObjectivesYaml(OutputStream out) throws IOException {
	YAMLFactory yf = new YAMLFactory();
	YAMLMapper mapper = new YAMLMapper();
	ObjectNode root = mapper.createObjectNode();
	for (Objective objective : objectives) {
		root.put(objective.getId().get(), objective.getInstruction().get());
	}
	yf.createGenerator(out).setCodec(mapper).writeObject(root);
}
 
开发者ID:Co0sh,项目名称:BetonQuest-Editor,代码行数:10,代码来源:QuestPackage.java


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