Skip to content

kkpagaev/rust-ts-json-compiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust zod compiler

Compiles zod schema to valid json payload.

Usage

pub fn main() {
    let zod_schema = "
    z.object({
        products: z.array(
          z.object({
            productId: z.number().int(),
            amount: z.number().int(),
            price: z.number()
          })
        ),
        cityId: z.number().int(),
        comment: z.string()
    })
    ";

    let json_schema = rust_ts_json_compiler::to_json(zod_schema);

    /* 
    {
        "products": [
            {
                "productId": 1,
                "amount": 1,
                "price": 5
            }
        ],
        "cityId": 1,
        "comment": "string"
    }
    */
    println!("{}", json_schema);
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors