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
- Host: GitHub
- URL: https://github.com/micartey/mvml
- Owner: micartey
- License: mit
- Created: 2024-08-30T14:17:05.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-09-08T21:32:29.000Z (almost 2 years ago)
- Last Synced: 2025-01-26T10:08:29.968Z (over 1 year ago)
- Topics: yaml, yml
- Language: Java
- Homepage:
- Size: 353 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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