authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-05-31 15:48:38 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-05-31 15:48:38 -07:00
logfb918b08846233573467f5df41fcc3b733155663
treeaf7d6df61451722e9ba8be0134c93c3231615ef6
parent099dae8feddcff6e671db1199a55d107bf97974e
signaturebadge-check Signed by SSH key SHA256:4hHJbtBRU58AYXwjL7fkz2fnQHdiye8x1QpTCQ0sHNw

ObjectIndex: add getAny


1 files changed, 13 insertions(+), 0 deletions(-)

json.zig+13
......@@ -642,6 +642,19 @@ pub const ObjectIndex = enum(u32) {
642642 return .{ k[0..len], v[0..len] };
643643 }
644644
645 pub fn getAny(this: ObjectIndex, needle: []const u8) ?ValueIndex {
646 const keys, const values = this.to();
647 for (keys, values) |k, v| {
648 if (std.mem.eql(u8, needle, k.to())) {
649 if (v.v() == .null) {
650 return null;
651 }
652 return v;
653 }
654 }
655 return null;
656 }
657
645658 pub fn get(this: ObjectIndex, needle: []const u8, comptime tag: Value.Tag) ?ValueIndex {
646659 const keys, const values = this.to();
647660 for (keys, values) |k, v| {