Ziggy: a JSON / YAML / TOML replacement

I started working on this project because I need a frontmatter data format for Zine, my static site generator, but I’m trying to make it a general purpose data format that should be an improvement over JSON & co for most similar use cases.

Key features:

  • distinction between structs vs maps
  • unions of structs, so that you don’t have to rely on shape matching

I have already created a tree sitter grammar, an LSP and a bunch of parsers for it.

There’s one last feature (custom string literals) that I’m still not fully sure about (mostly syntax-wise) but the two key features above are set in stone.

Try re-imagining some JSON / YAML / TOML files in Ziggy and see if you think they would be improved.


Super cool! I’m stuck using json since it’s a painless communication format between zig and python, and works good enough for first implementation of storage and network systems.

If I ever want to start configuring from json, this would be a neat alternative! Granted json has JSON Schema to do IDE autocomplete, which helps a tonne as well…

I can also imagine this would be nice just to get a quick debug log of some state in a more readable format.

What’s the difference between zon and ziggy?

  • Zon is part of Zig, Ziggy is my personal project
  • Zon at the moment is Zig struct/tuple literals “all the way down”
  • Ziggy is more expressive (at the cost of more syntax to learn)
    • structs vs maps
    • ability to omit curlies of the top-level struct
    • named struct unions (so that one doesn’t have to do shape-matching like in JSON when parsing)
    • custom string literals
  • Ziggy comes with a schema language (working on it as we speak)

I see that you’re testing addition in your root folder - always good to know that still works! ziggy/tree-sitter-ziggy/src/root.zig at main · kristoff-it/ziggy · GitHub

Joking aside, looks really clean! Great work :slight_smile:

Published a website with a bunch of documentation for Ziggy, I would recommend to the intrepid souls that want to try Ziggy out to download the Ziggy CLI tool and to see if their editor has syntax highlighting support for it.


1 Like

@kristoff Can I use ziggy’s schema language for a project of mine? It is called freightdb. If yes how can I use it to parse a .ziggy-schema file in zig? The project is still very early into development [it has only been about 2 weeks since development began]

Recently, Apple showcased their JSON/YAML/TOML replacement: Pickle

Check it out if you haven’t, there may be some interesting design choices you might like and adopt into Ziggy.

Cool idea, cool website, good luck! :muscle:

Sure I’ve published Ziggy so that others can use it too.

What is your intent wrt the Ziggy Schema file? If you want to have your application perform schema checking on a Ziggy Schema file, I can give you some pointers. If you want to use a Ziggy Schema to generate automatically a corresponding type, that’s not implemented yet. That said you can give a type to ziggy.parseLeaky and it will work.

Can ziggy parse a .ziggy-schmea file into Zig types?

This project is very cool!

Previously I had some random thoughts about using zig struct to as the intermediate format to generate JSON/TOML/YAML etc, even for protobuf, so users don’t need to install the protoc.

Ziggy just make my thought a reality!

By reading its docs, it seems function is not supported?

With function, I think Ziggy can easily generate config with lots of duplicated parts.

The reason why I’m holding off on using comptime to generate types from schemas (or vice versa) is because I want first to explore a codegen path (i.e. using the build system to write the computed artifact as a concrete file in the codebase) because I think it might be a more solid way of doing this work.

Using comptime for schema<>type interop sounds sexy but it has a number of downsides, one of which is the necessity to create comptime parsers and semantic checkers for the schema stuff, which in my opinion constitutes crossing the line of unwise usage of comptime.

So, PRs welcome for a build system based approach if anybody is in a rush, otherwise I will eventually get to it.

1 Like

As a person looking forward to use the ziggy-schema ina project I will gladly wait for the type generation. I believe you and I believe you will deliver with the type generation