From c2e2778d7764633ba0214ae5be62aa3c14c34e8a Mon Sep 17 00:00:00 2001 From: Emil Lerch Date: Wed, 23 Jun 2021 18:18:00 -0700 Subject: [PATCH] missing field support (not sure if we will use this) --- src/json.zig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/json.zig b/src/json.zig index c35773f..fcb4b72 100644 --- a/src/json.zig +++ b/src/json.zig @@ -1454,6 +1454,7 @@ pub const ParseOptions = struct { allow_camel_case_conversion: bool = false, allow_snake_case_conversion: bool = false, allow_unknown_fields: bool = false, + allow_missing_fields: bool = false, }; fn camelCaseComp(field: []const u8, key: []const u8, options: ParseOptions) !bool { @@ -1682,7 +1683,8 @@ fn parseInternal(comptime T: type, token: Token, tokens: *TokenStream, options: @field(r, field.name) = default; } } else { - return error.MissingField; + if (!options.allow_missing_fields) + return error.MissingField; } } }