50 lines
1.1 KiB
Zig
50 lines
1.1 KiB
Zig
const std = @import("std");
|
|
const sqlite = @import("sqlite");
|
|
|
|
const Db = @import("Db.zig");
|
|
const Item = @import("Item.zig");
|
|
const Tag = @import("Tag.zig");
|
|
const json = @import("json.zig");
|
|
|
|
pub fn main() !void {
|
|
var db = try Db.init();
|
|
|
|
//var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
|
|
//defer arena.deinit();
|
|
//const alloc = arena.allocator();
|
|
|
|
const jsonText: [:0]const u8 =
|
|
\\{
|
|
\\ "tags": {
|
|
\\ "title": "clean room",
|
|
\\ "task": null
|
|
\\ }
|
|
\\}
|
|
;
|
|
|
|
var jsonItem = json.Obj.newFromString(jsonText);
|
|
defer jsonItem.deinit();
|
|
|
|
_ = db;
|
|
|
|
//var item = Item.fromJson(jsonItem);
|
|
|
|
//try item.persist(&db);
|
|
|
|
//var jobj = item.toJson();
|
|
|
|
var jobj = jsonItem.objectGet("tags");
|
|
defer jobj.deinit();
|
|
|
|
var iter = jobj.objectGetIterator();
|
|
while(iter.next()) |*tag| {
|
|
std.debug.print("{s}", .{tag.key});
|
|
defer std.debug.print("\n", .{});
|
|
|
|
if (tag.value) |*value| {
|
|
std.debug.print(" => {s}", .{value.getString()});
|
|
}
|
|
}
|
|
|
|
}
|