mirror of
https://github.com/gocsaf/csaf.git
synced 2025-12-22 05:40:11 +01:00
Re-add unknown fields check (#681)
This commit is contained in:
parent
e3d2a58528
commit
05eae0a9ae
1 changed files with 2 additions and 0 deletions
|
|
@ -18,6 +18,8 @@ import (
|
||||||
// while not allowing trailing data
|
// while not allowing trailing data
|
||||||
func StrictJSONParse(jsonData io.Reader, target any) error {
|
func StrictJSONParse(jsonData io.Reader, target any) error {
|
||||||
decoder := json.NewDecoder(jsonData)
|
decoder := json.NewDecoder(jsonData)
|
||||||
|
// Don't allow unknown fields
|
||||||
|
decoder.DisallowUnknownFields()
|
||||||
|
|
||||||
if err := decoder.Decode(target); err != nil {
|
if err := decoder.Decode(target); err != nil {
|
||||||
return fmt.Errorf("JSON decoding error: %w", err)
|
return fmt.Errorf("JSON decoding error: %w", err)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue