missing field support (not sure if we will use this)

This commit is contained in:
Emil Lerch 2021-06-23 18:18:00 -07:00
parent 3d9490de82
commit c2e2778d77
Signed by: lobo
GPG Key ID: A7B62D657EF764F8

View File

@ -1454,6 +1454,7 @@ pub const ParseOptions = struct {
allow_camel_case_conversion: bool = false, allow_camel_case_conversion: bool = false,
allow_snake_case_conversion: bool = false, allow_snake_case_conversion: bool = false,
allow_unknown_fields: bool = false, allow_unknown_fields: bool = false,
allow_missing_fields: bool = false,
}; };
fn camelCaseComp(field: []const u8, key: []const u8, options: ParseOptions) !bool { 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; @field(r, field.name) = default;
} }
} else { } else {
return error.MissingField; if (!options.allow_missing_fields)
return error.MissingField;
} }
} }
} }