snakeyaml

SnakeYaml get stacked keys

淺唱寂寞╮ 提交于 2021-02-11 16:51:26
问题 When this is my .yml file: test1: "string1" test2: test3: "string2" How do I get the value of test3 ? Map<String, Object> yamlFile = new Yaml().load(YamlFileInputStream); yamlFile.get("test1"); // output: string1 yamlFile.get("test2"); // output: {test3=string2} yamlFile.get("test2.test3"); // output: key not found 回答1: YAML does not have „stacked keys“ . It has nested mappings. The dot . is not a special character and can occur normally in a key, therefore you cannot use it for querying

Does spring boot 2.1.x support yaml 1.2 specification

删除回忆录丶 提交于 2021-02-10 14:24:10
问题 Does spring boot 2.1.x support yaml 1.2 specification? If not, is it possible to use yaml 1.2 + snakeyaml-engine for the spring boot application.yml support? 回答1: Spring Boot uses snakeyaml 1.23. From the description this is YAML 1.1 <description>YAML 1.1 parser and emitter for Java</description> Because YAML is supported by snakeyaml-engine and not in snakeyaml the API is not compatible so you will not be able to use it in Spring Boot 来源: https://stackoverflow.com/questions/56558270/does

Does spring boot 2.1.x support yaml 1.2 specification

徘徊边缘 提交于 2021-02-10 14:23:42
问题 Does spring boot 2.1.x support yaml 1.2 specification? If not, is it possible to use yaml 1.2 + snakeyaml-engine for the spring boot application.yml support? 回答1: Spring Boot uses snakeyaml 1.23. From the description this is YAML 1.1 <description>YAML 1.1 parser and emitter for Java</description> Because YAML is supported by snakeyaml-engine and not in snakeyaml the API is not compatible so you will not be able to use it in Spring Boot 来源: https://stackoverflow.com/questions/56558270/does

SnakeYaml dump function writes with single quotes

梦想的初衷 提交于 2021-02-08 06:56:47
问题 Consider the following code: public void testDumpWriter() { Map<String, Object> data = new HashMap<String, Object>(); data.put("NAME1", "Raj"); data.put("NAME2", "Kumar"); Yaml yaml = new Yaml(); FileWriter writer = new FileWriter("/path/to/file.yaml"); for (Map.Entry m : data.entrySet()) { String temp = new StringBuilder().append(m.getKey()).append(": ").append(m.getValue()).toString(); yaml.dump(temp, file); } } The output of the above code is 'NAME1: Raj' 'NAME2: Kumar' But i want the

SnakeYaml dump function writes with single quotes

一个人想着一个人 提交于 2021-02-08 06:56:22
问题 Consider the following code: public void testDumpWriter() { Map<String, Object> data = new HashMap<String, Object>(); data.put("NAME1", "Raj"); data.put("NAME2", "Kumar"); Yaml yaml = new Yaml(); FileWriter writer = new FileWriter("/path/to/file.yaml"); for (Map.Entry m : data.entrySet()) { String temp = new StringBuilder().append(m.getKey()).append(": ").append(m.getValue()).toString(); yaml.dump(temp, file); } } The output of the above code is 'NAME1: Raj' 'NAME2: Kumar' But i want the

Dumping values with quotes with SnakeYaml

ⅰ亾dé卋堺 提交于 2021-02-05 07:45:07
问题 Having a simple yml file test.yml as follows color: 'red' I load and dump the file as follows final DumperOptions yamlOptions = new DumperOptions(); yamlOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); Yaml yaml = new Yaml(yamlOptions); Object result = yaml.load(new FileInputStream(new File("test.yml"))); System.out.println(yaml.dump(result)); I expect to get color: 'red' However, the during the dump, the serializer leaves out the quotes and prints color: red How can I make the

How to auto edit Yaml file containing Anchors & Aliases using snakeyaml

孤人 提交于 2021-01-28 11:44:10
问题 I want to automate YAML file processing using snake YAML Input: _Function: &_Template Name: A Address: B _Service: &_Service Problem1: <<: *_Template Problem2: <<: *_Template Function.Service: Service1: <<: *_Service Service2: <<: *_Service After Modifying the desired output is _Function: &_Template Name: A Address: B _Service: &_Service Problem1: <<: *_Template Problem2: <<: *_Template Function.Service: Service1: <<: *_Service Service2: <<: *_Service Service2: <<: *_Service Is it possible to

Polymorphic collections in SnakeYaml

我的未来我决定 提交于 2021-01-27 04:20:57
问题 My intention is to have polymorphic collections like the ones in JSON using jackson, maybe with the help of tags. I can't seem to able to configure it properly tho. My yaml file is: !person age: 27 job: dev name: me skills: - !devSkill { description: 'software development', name: android, language: java, c++ years: 7 } - !softSkill { description: 'good person', name: <3, reason: lots of NGO work } - !sportsSkill { description: 'racing legend', name: vrooom, championships: - San Marino 2012 -

Polymorphic collections in SnakeYaml

我只是一个虾纸丫 提交于 2021-01-27 04:16:33
问题 My intention is to have polymorphic collections like the ones in JSON using jackson, maybe with the help of tags. I can't seem to able to configure it properly tho. My yaml file is: !person age: 27 job: dev name: me skills: - !devSkill { description: 'software development', name: android, language: java, c++ years: 7 } - !softSkill { description: 'good person', name: <3, reason: lots of NGO work } - !sportsSkill { description: 'racing legend', name: vrooom, championships: - San Marino 2012 -