rust-ts-json-compiler

Crates.iorust-ts-json-compiler
lib.rsrust-ts-json-compiler
version0.2.0
sourcesrc
created_at2023-10-24 10:08:33.393943
updated_at2023-11-20 13:56:37.453669
descriptionts-zod compiller to json
homepage
repository
max_upload_size
id1012226
size29,381
kkpagaev (kkpagaev)

documentation

README

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);
}

Commit count: 0

cargo fmt