-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Documentation on ZON files #15552
Comments
Do we have a standing example now? I don't find a |
Not sure, but it should be there by 0.12.0, so... Anyway, the syntax is very simple, just anonymous nested structs, like so: .{
.foo = .{
.a = "hello",
}
} (then, they can be imported just like JSON in node.js) Whenever the build system starts using ZON files we will see them on the repo I guess EDIT: Zig compiler doesn't need a |
A major flaw with json is its inability to store non-UTF8 strings which inadvertently makes them unreliable for storing unix filenames (here a filename is defined as any sequence of bytes except Will or does zon address this issue? Some prior art on this would be Rust's |
ZON strings are no different from Zig string literals in this context, so the answer is: yes, ZON strings store any sequence of bytes, agnostic to their interpretation. The literal in file must itself be UTF-8 encoded, because Zig sources - and by extension ZON - are always UTF-8 encoded, but you can represent any byte sequence which is not valid UTF-8 by using simple escape sequences (the main relevant one here being |
This is what I hope for, essentially exposing zig's string literals directly, but if zon is to be like json and independent of language then perhaps these aspects should be made explicit when documenting the format? Then tools like fq can pick up the format making it useful for a wider array of purposes. |
Now that i'm thinking about this, it would be wise to wait for #14531, and document everything at once. More importantly, some aspects of ZON files might change. |
as of f7bc55c there is documentation here: https://github.com/ziglang/zig/blob/master/doc/build.zig.zon.md |
Closing this may be premature as that commit doesn't document ZON format, but instead documents the |
I totally agree with @Earnestly, having documentation for |
I definitely agree we should have documentation on the ZON format itself, not just the schema of |
In the meantime, since there's no documentation on ZON, could someone please tell if ZON supports arrays? If yes, what is the syntax? Is it Or is it something different? |
You should think of a .foo = .{
something,
hello_there,
},
The first one would work perfectly. The second one is not even valid in normal zig code. But yeah, the first one should pass, as (someone correct me if I missed something) |
Thank you. I have since written a small library (if it could be called that) to help extract field values from the ZON AST generated with I don't want to hijack the comments for this issue.. but you wouldn't happen to know why negative numbers (field values) are represented by two tokens in AST - the minus sign ("-") and the number itself? |
Well, most compilers do that. And it kind of makes sense, as |
Now that ZON files (Zig Object Notation) are a thing, they should be documented in langref
ZON files described on #14523
The text was updated successfully, but these errors were encountered: