An open API service indexing awesome lists of open source software.

https://github.com/micartey/mvml

The worlds worst take at yaml
https://github.com/micartey/mvml

yaml yml

Last synced: 6 months ago
JSON representation

The worlds worst take at yaml

Awesome Lists containing this project

README

          

# mvml











> [!IMPORTANT]\
> mvml is my bad try at somewhat reading and writing yaml files while preserving comments.
> This markup language is not according to yml specifications and I DO NOT recommend using it in production.

## 📚 Introduction

`mvml` (micarteys version of a markup language) is essentially a yaml clone with less features and without following the specification.
Yaml specification doesn't respect comments, thus breaking yaml files with comments when writing to it.
As this is very annoying and unwanted behaviour, I tried to create a parser which supports the yaml structure and respects comments.

### Usage

The following syntax is currently supported:

```yaml
# Some comment
# in multiple lines

my:
# Some other comment
field: 123

# List representation will look like this
list: ["Some", "String", "Array"]

root-level-field: false
```

This is not much, but sufficient for most configurations.
If you want to use lists, you might want to represent them as arrays in a single line instead of a list as per usual.
The mvml parser gives you a string without trying to interpret it, altough this might be added in the future.

```java
MvmlParser parser = new MvmlConfiguration(file)
.setTemplate(stream)
.load();

String value = parser.get("my.field"); // Returns 123
```

Please check out the [JavaDocs](https://micartey.github.io/mvml/docs/me/micartey/mvml/MvmlParser.html) for an overview of all avialable operations.

## Parse Custom Types

If you want to parse custom data, make sure your object has the following to methods:

```java
@Override
public String toString() {
// return a String represetation
}

public YouDataType valueOf(String representation) {
// return instance of YouDataType from String representation
}
```

These methods will automatically be invoked by mvml when calling the [**get(field, class)**](https://micartey.github.io/mvml/docs/me/micartey/mvml/MvmlParser.html#get(java.lang.String,java.lang.Class)) method