jason-rs 0.2.3

A library for parsing Jason-like files into JSON, YAML, or TOML with support for inline file expansion.
Documentation

jason-RS

Crates.io Docs License

jason is a lightweight JSON templating tool that transforms reusable .jason template files into standard JSON. Build modular and composable JSON structures with parameter support and file inclusion.

✨ Features

  • Template Parameters - Define reusable templates with named parameters
  • File Inclusion - Compose JSON from multiple .jason files
  • 1:1 Conversion - Clean mapping from .jason syntax to standard JSON
  • Library-First - Designed for seamless integration into Rust projects

🚀 Quick Start

Add jason-rs to your Cargo.toml:

[dependencies]
jason-rs = "0.1"

Parse a Jason file:

use jason_rs::jason_to_json;

fn main() {
    //outputs raw json source
    let json = jason_to_json("./Page.jason").unwrap();
    println!("{}", json);
}

Example

Jason Templates

Person.jason - A reusable person template

(name, age) {
    "name": #name,
    "age": #age
}

Studio.jason - A static studio object

{
    "name": "GameInc",
    "ceo": "Dave Something"
}

Team.jason - Composing multiple templates

(project) {
    "studio": <./Studio.jason>,
    "project": #project,
    "workers": [
        <./Person.jason | "jay", 12>,
        <./Person.jason | "mark", 14>,
        <./Person.jason | "lee", 15>
    ]
}

Page.jason - The head of the composition.

{
    "team": <./Team.jason | "Mario">
}

Generated JSON

{
  "team": {
    "project": "Mario",
    "studio": {
      "name": "GameInc",
      "ceo": "Dave Something"
    },
    "workers": [
      {
        "name": "jay",
        "age": 12
      },
      {
        "name": "mark",
        "age": 14
      },
      {
        "name": "lee",
        "age": 15
      }
    ]
  }
}

Syntax Overview

Syntax Description
(param1, param2) Define template parameters
#param Reference a parameter value
<./File.jason> Include another Jason file
<./File.jason | arg1, arg2> Include with arguments

Parses a .jason file at the given path and returns the resulting JSON as a String.

License

Licensed under the Apache License 2.0. See LICENSE for details.