No description
Find a file
George Lemon c7811b480e update
Signed-off-by: George Lemon <georgelemon@protonmail.com>
2025-12-11 06:55:32 +02:00
.github/workflows Update test.yml 2023-10-24 09:52:09 +03:00
src update 2025-12-11 06:55:32 +02:00
tests fix test bad output 2024-04-18 21:40:17 +03:00
.gitignore remove 1.4.x 2022-08-06 15:23:13 +03:00
LICENSE Initial commit 2021-10-20 21:19:30 +03:00
nyml.nimble bump 2024-04-24 19:06:21 +03:00
README.md Update README.md 2024-03-27 16:22:29 +02:00

😋 A stupid simple YAML Parser.
From YAML to stringified JSON, JsonNode or Nim objects via pkg/jsony

nimble install nyml

API reference

Github Actions Github Actions

😍 Key Features

  • integer, string, boolean, array, object
  • GET access using dot annotations
  • Direct to object parser using JSONY
  • Rules and Validator
  • Open Source | MIT License

Example

A simple YAML file
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

let contents = readFile("sample.yaml")
let jsonContents: JsonNode = yaml(contents).toJson.get

Get a specific value using . notation

let osName: JsonNode = yaml(contents).toJson.get("jobs.test.runs-on")
echo osName.getStr

Handle variables

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

echo yaml(contents)

# dump to json with indentation
echo yaml(contents, true)

❤ Contributions & Support

🎩 License

MIT license. Made by Humans from OpenPeeps.
Copyright © 2023 OpenPeeps & Contributors — All rights reserved.