This Java API provides an easy-to-use way to store data and provide configurations using the YAML format.
YAML is a human-readable data-oriented serialization language.
Serialization is the process of translating data structures or object state into a format that can be stored and reconstructed later in the same or another computer environment.
You can learn more about YAML language here. Specifically, if you're interested to learn about the YAML syntax you can go to the Chapter 2 of the YAML specification.
Filename extensions: .yaml
, .yml
Simple-YAML is a library designed to create configuration files for your programs, tools and plugins.
The API is a port from Bukkit configuration wrapper with some features added, so you can use this library wherever you want without Bukkit dependency.
Simplicity is added with the YamlFile
class, which has everything you need with easy use for creation, management and serialization of yaml files. It is an extension of YamlConfiguration
.
Furthermore, you can optionally save your files with comments in mind. You can write your comments with a text editor as usual. In addition, not only you can preserve your comments but also with this API you can read and add comments programmatically to your configuration. Sounds good, right?
To use this API all you need is to download the latest Simple-Yaml.jar and put it as a dependency on your project.
If you are using Maven you do not need to download the jar. Instead, add this repository and dependency to your pom.xml
:
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Yaml + Configuration
<dependency>
<groupId>com.github.Carleslc.Simple-YAML</groupId>
<artifactId>Simple-Yaml</artifactId>
<version>1.8.4</version>
</dependency>
You can also use me.carleslc.Simple-YAML
as the groupId.
Configuration only
<dependency>
<groupId>com.github.Carleslc.Simple-YAML</groupId>
<artifactId>Simple-Configuration</artifactId>
<version>1.8.4</version>
</dependency>
You can also use me.carleslc.Simple-YAML
as the groupId.
If you are using Gradle you do not need to download the jar. Instead, add this repository and dependency to your build file:
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
Yaml + Configuration
dependencies {
implementation 'com.github.Carleslc.Simple-YAML:Simple-Yaml:1.8.4'
}
Configuration only
dependencies {
implementation 'com.github.Carleslc.Simple-YAML:Simple-Configuration:1.8.4'
}
The best way to learn how to use this API is through some examples.
You can find some examples to test here.
YamlExample
: An example to create YAML files, save or delete values and move through the file configuration.YamlCommentsExample
: An example to load and save YAML files keeping comments and also how to read and add comments programmatically.YamlCommentsFormatExample
: An example to format header and comments with custom prefixes, suffixes and blank lines.YamlEncodingExample
: A minimal example to check your encoding with Unicode characters.YamlSerializationExample
: An example for saving complex objects using serialization.Person
: An example of class for complex objects used in the previous file. Here you can see how to serialize and deserialize objects.
Find the example .yml
files here.
For more information and methods see the Javadoc:
This API uses SnakeYAML underneath. It is already included in the latest Simple-Yaml.jar and with the maven or gradle dependencies.
Have a look to these repositories:
These projects are using the Simple-Configuration module, but they are not related directly with Simple-YAML.