ziglibs / tres Goto Github PK
View Code? Open in Web Editor NEWValueTree-based JSON parser
License: MIT License
ValueTree-based JSON parser
License: MIT License
pub const A = struct {
pub const tres_null_meaning = .{.{"a", .field}, .{"b", .null}, .{"c", .dual}};
a: ?u8 = null,
b: ?u8 = null,
c: ??u8 = @as(?u8, null),
};
becomes
{"b": null, "c": null}
Useful for differentiating between abc?
fields and abc: ... | null
LSP fields.
??
dual fields are non-existent on the first null, then null on the second null. This eliminates the need for Undefinedable
which is just super clunky to use.
pub const Document = struct {
revision: ??[]const u8,
description: ??[]const u8,
};
parsing the preceding results in this compile error:
/Users/haze/.cache/zig/p/1220beaae8d152baa941a10b7ef3d3a59d093b257047035e2373c3c2f876ad29ccc8/tres.zig:549:69: error: unable to evaluate comptime expression
} else if (comptime dualable(field.type) and nm == .dual) {
~~~^~~~~~~~
/Users/haze/.cache/zig/p/1220beaae8d152baa941a10b7ef3d3a59d093b257047035e2373c3c2f876ad29ccc8/tres.zig:549:66: note: operation is runtime due to this operand
} else if (comptime dualable(field.type) and nm == .dual) {
(parsed like so)
var arena = std.heap.ArenaAllocator.init(std.testing.allocator);
defer arena.deinit();
var parser = std.json.Parser.init(arena.allocator(), false);
const tree = try parser.parse(data);
const document = try tres.parse(Document, tree.root, arena.allocator());
std.log.warn("{}", .{document});
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.