Questions tagged [snakeyaml]

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

395 questions
7
votes
1 answer

Polymorphic collections in SnakeYaml

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 { …
MLProgrammer-CiM
  • 17,231
  • 5
  • 42
  • 75
7
votes
1 answer

Java and YAML: how to parse multiple yaml documents and merge them to a single YAML representation?

Let's say I have one file, defaults.yaml: pool: idleConnectionTestPeriodSeconds: 30 idleMaxAgeInMinutes: 60 partitionCount: 4 acquireIncrement: 5 username: dev password: dev_password and another file, production.yaml: pool: username:…
Les Hazlewood
  • 18,480
  • 13
  • 68
  • 76
7
votes
2 answers

Load .yml file into hashmaps using snakeyaml (import junit library)

I am trying to load opencv's .yml file into arrayLists mean, projection and labels. I ve create those three arraylists and I am trying to parse into them the elements from the .yml file. I ve found snakeYAML documentation . However I didnt find a…
snake plissken
  • 2,649
  • 10
  • 43
  • 64
7
votes
0 answers

Can't construct a java object for tag:yaml.org,2002:

When I am trying to create an object from a data file, I am getting the following exception while assest class is present. I have tried with dum; it was able to dump the data but when I have tried to read same data I am getting the following…
user1047873
  • 230
  • 3
  • 8
  • 28
7
votes
1 answer

Adding a Comment to a Node With SnakeYaml

As part of a large project I am working on, I am constructing a YAML file in memory, and then dumping it to a file, using SnakeYaml in this entire process. My YAML file is around 500 lines long and meant to be used by people who have no programming…
Xyene
  • 2,304
  • 20
  • 36
6
votes
2 answers

How can I control yaml indentation using SnakeYaml during dumping?

I am using snakeyaml library to parse yaml files, and dump it later from xml. I was wondering if there is any way to control final yaml indentation. For example, list in final file will look like this: list: - "first item" - "second item" I would…
6
votes
1 answer

SnakeYAML formatting - remove YAML curly brackets

I have a code that is dumping a linkedhashmap into a YAML object public class TestDump { public static void main(String[] args) { LinkedHashMap values = new LinkedHashMap(); values.put("one", 1); …
Mark Estrada
  • 9,013
  • 37
  • 119
  • 186
6
votes
1 answer

How to define a Map in a YAML file in the Play! framework?

I'm using the Play! framework and I have a model (an Entity) that has a variable of type Map. To make some tests, I load a YAML file every time I start the application, but I don't know the syntax to define a Map. Let's say I have this class public…
Marc-François
  • 3,900
  • 3
  • 28
  • 47
6
votes
2 answers

Loading multiple YAML files (using @ConfigurationProperties?)

Using Spring Boot 1.3.0.RELEASE I have a couple of yaml files that describe several instances of a program. I now want to parse all those files into a List (Map, whatever), so I can later on search for the most appropriate instance for a…
Alex
  • 101
  • 1
  • 1
  • 8
6
votes
1 answer

Deserialize yaml to list of objects

Say I have a Yaml file like this, people: - name : Joe surname : Barber age : 16 - name : Andy surname : Lots age : 17 And I have a class like this, public class people { private String name; private String…
Ernie
  • 567
  • 2
  • 6
  • 23
6
votes
3 answers

Nested Constructs with SnakeYAML

I'm looking at using custom constructs with SnakeYAML and am not sure how to implement nesting. I'm using this example as reference. In the linked example, the relevant YAML and Construct is, - !circle center: {x: 73, y: 129} radius:…
user1080806
6
votes
3 answers

Parsing YAML Front matter in Java

I have to parse YAML Front Matter in java like jekyll, So Iooked into the source code, and found this but I can't make much sense of it(I don't know much ruby). So My Question is, How do I parse YAML Front Matter in java ? I have snakeyaml in my…
Gautam
  • 7,868
  • 12
  • 64
  • 105
5
votes
1 answer

How to parse part of .yaml file to object in SnakeYAML?

I have a yaml file, for example: # this is the part I don't care about config: key-1: val-1 other-config: lang: en year: 1906 # below is the only part I care about interesting-setup: port: 1234 validation: false parts: - on-start:…
Benjamin
  • 3,217
  • 2
  • 27
  • 42
5
votes
2 answers

How to serialize fields with custom names using snake yaml in Java

I'm trying to serialize a Java instance having fields like follows. public class Person{ private String firstName; private String lastName; public String getFirstName() { return firstName; } public void…
Kasun Siyambalapitiya
  • 3,956
  • 8
  • 38
  • 58
5
votes
3 answers

How to Access the inner(nested) key-value in an YAML file using snakeYaml Library

I am trying to read config.yaml file using the snakeYaml library in java. I am able to get the Module name (i.e [{ABC=true}, {PQR=false}]) in my config file. Is there a way where I can directly read the value of ABC (ie true) using the code. I have…
Alok
  • 1,441
  • 4
  • 20
  • 31
1 2
3
26 27