Skip to content

Instantly share code, notes, and snippets.

@Aloso
Last active March 10, 2022 15:28
Show Gist options
  • Save Aloso/0835609963f0d49d32b837f09307462a to your computer and use it in GitHub Desktop.
Save Aloso/0835609963f0d49d32b837f09307462a to your computer and use it in GitHub Desktop.

YASON: Yet another simple object notation

  • Backwards compatible with JSON and JSONC

  • Quotes on keys are optional if they only contain letters, digits, _, -, ., @, /

  • Commas are optional

  • Trailing commas are allowed

  • Multiline strings:

    {
      test: | This is absolutely awesome!
              I love it!
      test2: |
        I love this, too!
    }
  • ADT shorthands:

    {
      colors: [
        Rgb [0, 50, 30],
        "red",
        Hsl {
          hue: Deg 300,
          sat: 1,
          lum: 0.5,
        },
      ]
    }

    The above is equivalent to

    {
      "colors": [
        {
          "Rgb": [0, 50, 30]
        },
        "red",
        {
          "Hsl": {
            hue: { "Deg": 300 },
            sat: 1,
            lum: 0.5
          }
        }
      ]
    }
  • Schema support

  • Lisp-style syntax extensions

    (fn x y {
      foo: (case x
        is 3 => { bar: "baz" }
        is 4+ => (str "baz " x)
        is null => null
        else => +Rgb [(y), 50, 30]
      )
    })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment