Questions tagged [snakeyaml]

SnakeYAML is a YAML parser and emitter for the Java programming language.

395 questions
50
votes
2 answers

How to define a map in a YAML file for simple POJO?

I am using SnakeYAML to parse certain configuration/property values to a Configuration object (defined below). My YAML file looks like this: # Thread batchLimit: 1000 threadCountLimit: 2 # Some more config key: value # Map keyMapping:
frugalcoder
  • 959
  • 2
  • 11
  • 23
41
votes
4 answers

gpg: Sorry, no terminal at all requested - can't get input

When decrypting I get following error: $ eyaml decrypt -s 'ENC and the key goes on here' .gnupg --quiet --no-secmem-warning --no-permission-warning --no-tty --yes --decrypt) failed with: gpg: Sorry, no terminal at all requested - can't get input I…
31
votes
5 answers

Spring Boot: read list from yaml using @Value or @ConfigurationProperties

I want to read a list of hosts from a yaml file (application.yml), the file looks like this: cors: hosts: allow: - http://foo1/ - http://foo2/ - http://foo3/ (Example 1) My class used defines the…
Marged
  • 10,577
  • 10
  • 57
  • 99
19
votes
2 answers

Ignore fields from yaml when parsing it using SnakeYaml (Unable to find property on class)

I am using SnakeYaml to parse yaml file, is there anyway to ignore properities from the yaml file ?
Bilal Halayqa
  • 932
  • 1
  • 6
  • 25
18
votes
4 answers

upgrade to SnakeYaml 1.31 in spring-boot-starter-parent 2.7.3

Have springboot project in which wanted to either exclude snakeyaml 1.30 or upgrade it 1.31 inorder to avoid fortify issue reporting with snakeyaml 1.30 version there is security vulnerability
Syed Rafi
  • 825
  • 2
  • 12
  • 35
16
votes
4 answers

How do I write to a YAML file using SnakeYaml?

Consider the following code: public static void dumpObjectToYaml(String key, Object O, String path) throws IOException { Map data = new HashMap<>(); data.put(key, O); File F = new File(path); F.mkdirs(); …
Jonas Bartkowski
  • 357
  • 1
  • 6
  • 15
15
votes
2 answers

Sping-Boot Config: How to keep whitespace in yaml key being used to populate Map

Let's say we have a configuration properties class: @ConfigurationProperties(prefix = "whitespace.test") public class WhitespaceTestConfig { private Map configs; public Map getConfigs() { return…
MochiJump
  • 319
  • 3
  • 10
14
votes
1 answer

Include YAML files from snakeyaml

I would like to have YAML files with an include, similar to this question, but with Snakeyaml: How can I include an YAML file inside another? For example: %YAML 1.2 --- !include "load.yml" !include "load2.yml" I am having a lot of trouble with it.…
Blazes
  • 4,721
  • 2
  • 22
  • 29
13
votes
1 answer

Spring Boot YAML configuration with URL in key no longer loads correctly with version 2

I'm migrating my application from Spring Boot 1.5 to 2.0 and one of the YAML properties no longer loads correctly. The following configuration snippet: myapp serviceUrls: 'https://example.org/test': 'https://test.example.org/Endpoint' is…
Kolargol00
  • 1,697
  • 2
  • 17
  • 21
12
votes
2 answers

How to parse part of a YAML file in SnakeYaml

I am new to YAML and have parse a YAML config file that looks like: applications: authentication: service-version: 2.0 service-url: https://myapp.corp/auth app-env: DEV timeout-in-ms: 5000 enable-log: true service1: …
Niranjan
  • 2,601
  • 8
  • 43
  • 54
12
votes
5 answers

Parsing a YAML document with a map at the root using snakeYaml

I want to read a YAML document to a map of custom objects (instead of maps, which snakeYaml does by default). So this: 19: typeID: 2 limit: 300 20: typeID: 8 limit: 100 Would be loaded to a map which looks like this: Map
Justas
  • 811
  • 1
  • 11
  • 22
11
votes
3 answers

Java SnakeYaml - prevent dumping reference names

I have the following method which I use to get the object converted to yaml representation (which I can eg. print to console) @Nonnull private String outputObject(@Nonnull final ObjectToPrint packageSchedule) { DumperOptions options = new…
Kris
  • 5,714
  • 2
  • 27
  • 47
10
votes
2 answers

How to read from YAML file in java?

I have YAML file like this.. Product: ProductA: Suite: SuiteName_A: Environment_1: ["A","B","C"] Environment_2: ["X","Y","Z"] SuiteName_B: Environment_1: ["E","F","G"] Environment_2: ["K","L","M"] ProductB: …
Koushik J
  • 552
  • 3
  • 10
  • 23
10
votes
1 answer

Filter out null fields in snakeyaml

I am using snakeyaml to print my object in a YAML file. There are some fields which could be null. How can I prevent these field, when they are null from being printed in the file?
warrior107
  • 709
  • 1
  • 9
  • 25
9
votes
5 answers

Getting java.lang.NoSuchMethodError: org.yaml.snakeyaml.Yaml. while running spark based spring boot application

SnakeYaml jar present at classPath: snakeyaml-1.26.jar 2330 [main] ERROR org.springframework.boot.SpringApplication - Application run failed java.lang.NoSuchMethodError:…
IAmHere
  • 113
  • 1
  • 1
  • 5
1
2 3
26 27