allow unknown non-struct fields

This commit is contained in:
Emil Lerch 2021-05-13 07:56:43 -07:00
parent 0bafc185c8
commit c24ef3f3b8
Signed by: lobo
GPG Key ID: A7B62D657EF764F8

View File

@ -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,
}