From fb918b08846233573467f5df41fcc3b733155663 Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Sun, 31 May 2026 15:48:38 -0700 Subject: [PATCH] ObjectIndex: add getAny --- json.zig | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/json.zig b/json.zig index 6b8fb31f509331da35ef3adeda25103c7f7912a3..cdcb9add9d58f572ea5a0df47662aa81305d71c0 100644 --- a/json.zig +++ b/json.zig @@ -642,6 +642,19 @@ pub const ObjectIndex = enum(u32) { return .{ k[0..len], v[0..len] }; } + pub fn getAny(this: ObjectIndex, needle: []const u8) ?ValueIndex { + const keys, const values = this.to(); + for (keys, values) |k, v| { + if (std.mem.eql(u8, needle, k.to())) { + if (v.v() == .null) { + return null; + } + return v; + } + } + return null; + } + pub fn get(this: ObjectIndex, needle: []const u8, comptime tag: Value.Tag) ?ValueIndex { const keys, const values = this.to(); for (keys, values) |k, v| { -- 2.54.0