Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/devatherock/simple-yaml
A simple YAML generator for Java
https://github.com/devatherock/simple-yaml
java yaml yaml-generator
Last synced: 2 months ago
JSON representation
A simple YAML generator for Java
- Host: GitHub
- URL: https://github.com/devatherock/simple-yaml
- Owner: devatherock
- License: mit
- Created: 2020-04-12T20:42:58.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-08-18T20:04:09.000Z (4 months ago)
- Last Synced: 2024-08-18T21:23:16.689Z (4 months ago)
- Topics: java, yaml, yaml-generator
- Language: Java
- Homepage: https://bintray.com/devatherock/simple-yaml/simple-yaml
- Size: 259 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[![CircleCI](https://img.shields.io/circleci/project/github/devatherock/simple-yaml/master.svg)](https://circleci.com/gh/devatherock/simple-yaml)
[![Download](https://img.shields.io/maven-central/v/io.github.devatherock/simple-yaml)](https://mvnrepository.com/artifact/io.github.devatherock/simple-yaml)
[![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=simple-yaml&metric=ncloc)](https://sonarcloud.io/dashboard?id=simple-yaml)
[![Coverage Status](https://coveralls.io/repos/github/devatherock/simple-yaml/badge.svg?branch=master)](https://coveralls.io/github/devatherock/simple-yaml?branch=master)
[![Quality Gate](https://sonarcloud.io/api/project_badges/measure?project=simple-yaml&metric=alert_status)](https://sonarcloud.io/component_measures?id=simple-yaml&metric=alert_status&view=list)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
# simple-yaml
A simple YAML generator for Java## Usage
For Gradle:
```groovy
dependencies {
implementation group: 'io.github.devatherock', name: 'simple-yaml', version: '0.3.0'
}
```For Maven:
```xml
io.github.devatherock
simple-yaml
0.3.0
```
### Generating YAML
#### With default settings
```java
Map map = new HashMap<>();
map.put("foo", "bar");
map.put("version", "1");
map.put("colors", Arrays.asList("red", "blue"));
String output = SimpleYamlOutput.toYaml(map);
```Output:
```yaml
foo: bar
version: 1
colors:
- red
- blue
```#### With custom settings
```java
Map map = new HashMap<>();
map.put("foo", "bar");
map.put("version", "1");
map.put("colors", Arrays.asList("red", "blue"));
SimpleYamlOutput yaml = SimpleYamlOutput.builder()
.numericFieldToQuote("version")
.flowStyleArrayField("colors")
.indentArrays(false)
.indentSize(3)
.quoteType(SimpleYamlOutput.QuoteType.SINGLE)
.build();
String output = yaml.dump(map);
```Output:
```yaml
foo: bar
version: '1'
colors: [ red, blue ]
```