From c24ef3f3b8283e85d20802e6d13d8e629918edef Mon Sep 17 00:00:00 2001 From: Emil Lerch Date: Thu, 13 May 2021 07:56:43 -0700 Subject: [PATCH] allow unknown non-struct fields --- src/json.zig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/json.zig b/src/json.zig index ed26c13..48b88f5 100644 --- a/src/json.zig +++ b/src/json.zig @@ -1450,6 +1450,8 @@ pub const ParseOptions = struct { Error, UseLast, } = .Error, + + allow_unknown_fields: bool = false, }; fn parseInternal(comptime T: type, token: Token, tokens: *TokenStream, options: ParseOptions) !T { @@ -1586,7 +1588,7 @@ fn parseInternal(comptime T: type, token: Token, tokens: *TokenStream, options: break; } } - if (!found) return error.UnknownField; + if (!found and !options.allow_unknown_fields) return error.UnknownField; }, else => return error.UnexpectedToken, }