Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/toolcreator/simpleyaml.lua
Very simple, dependency-free (subset of) YAML parser
https://github.com/toolcreator/simpleyaml.lua
lua yaml
Last synced: 4 months ago
JSON representation
Very simple, dependency-free (subset of) YAML parser
- Host: GitHub
- URL: https://github.com/toolcreator/simpleyaml.lua
- Owner: toolcreator
- License: mit
- Created: 2022-09-23T14:25:38.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-10-30T13:54:34.000Z (over 2 years ago)
- Last Synced: 2024-07-30T21:07:04.067Z (7 months ago)
- Topics: lua, yaml
- Language: Lua
- Homepage:
- Size: 10.7 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
# simpleyaml.lua
Very simple [YAML](https://yaml.org/) parser written in Lua.
Features:
- understands a "useful" subset of YAML
- parses correct files
- line-based parser, each line needs to contain a key
- almost no error handling
- no dependencies
- single-file## Example
Input:
```yaml
---# Example
someExample:
someKey: Here is some string
anotherKey: 42
subExample1:
foo: bar
subExample2:
hello: worldanotherExample:
thats: it
```Output:
```
{
anotherExample = {
thats = "it"
},
someExample = {
anotherKey = "42",
someKey = "Here is some string",
subExample1 = {
foo = "bar"
},
subExample2 = {
hello = "world"
}
}
}
```## Documentation
Example usage:
```lua
simpleyaml = require("simpleyaml.lua")
local parsed = simpleyaml.parse_file("path/to/file.yaml")
```Functions:
- `parse_file(path)`
Takes a `path` to a YAML file and returns a table representing the key-value pairs in the file.
No type conversions are performed, there are only strings.
May return `nil` in case of error.