https://github.com/openpeeps/nyml
A stupid simple YAML Parser. From YAML to stringified JSON, JsonNode or Nim objects. Written in Nim language 👑
https://github.com/openpeeps/nyml
json nim nim-language nyml yaml yaml-parser yaml2json yml-parser
Last synced: 5 months ago
JSON representation
A stupid simple YAML Parser. From YAML to stringified JSON, JsonNode or Nim objects. Written in Nim language 👑
- Host: GitHub
- URL: https://github.com/openpeeps/nyml
- Owner: openpeeps
- License: mit
- Created: 2021-10-20T18:19:29.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-05-10T13:55:13.000Z (12 months ago)
- Last Synced: 2024-05-10T14:54:36.862Z (12 months ago)
- Topics: json, nim, nim-language, nyml, yaml, yaml-parser, yaml2json, yml-parser
- Language: Nim
- Homepage: https://openpeeps.github.io/nyml
- Size: 270 KB
- Stars: 19
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
😋 A stupid simple YAML Parser.
FromYAML
to stringifiedJSON
,JsonNode
orNim
objects viapkg/jsony
nimble install nyml
## 😍 Key Features
- [x] `integer`, `string`, `boolean`, `array`, `object`
- [x] `GET` access using `dot` annotations
- [x] Direct to object parser using [JSONY](https://github.com/treeform/jsony)
- [x] Rules and Validator
- [x] Open Source | `MIT` License## Example
A simple YAML file
```yaml
name: test
on:
push:
paths-ignore:
- LICENSE
- README.*
pull_request:
paths-ignore:
- LICENSE
- README.*
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
nim-version:
- 'stable'
steps:
- uses: actions/checkout@v2
- uses: jiro4989/setup-nim-action@v1
with:
nim-version: ${{ matrix.nim-version }}
repo-token: ${{ secrets.GITHUB_TOKEN }}
- run: nimble install -Y
- run: nim --threads:on c -r src/tim.nim
- run: nimble test```
### Get JSON document
```nim
let contents = readFile("sample.yaml")
let jsonContents: JsonNode = yaml(contents).toJson.get
```### Get a specific value using `.` notation
```nim
let osName: JsonNode = yaml(contents).toJson.get("jobs.test.runs-on")
echo osName.getStr
```### Handle variables
```nim
let example = """
name: ${{username}}
"""
let yml = yaml(example, data = %*{"username": "John Do The Do"})
echo yml # {"name": "John Do The Do"}
```### Dump YAML to stringified JSON
```nim
echo yaml(contents)# dump to json with indentation
echo yaml(contents, true)```
### ❤ Contributions & Support
- 🐛 Found a bug? [Create a new Issue](https://github.com/openpeeps/nyml/issues)
- 👋 Wanna help? [Fork it!](https://github.com/openpeeps/nyml/fork)
- 😎 [Get €20 in cloud credits from Hetzner](https://hetzner.cloud/?ref=Hm0mYGM9NxZ4)
- 🥰 [Donate to OpenPeeps via PayPal address](https://www.paypal.com/donate/?hosted_button_id=RJK3ZTDWPL55C)### 🎩 License
`MIT` license. [Made by Humans from OpenPeeps](https://github.com/openpeeps).
Copyright © 2023 OpenPeeps & Contributors — All rights reserved.