strictjson

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 23, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Unmarshal

func Unmarshal(data []byte, v any) error

Unmarshal unmarshals JSON data into the provided struct v while ensuring strict validation of the input.

It checks for any extra or missing fields in the JSON data that do not match the struct definition.

Unlike json.Unmarshal, Unmarshal is case-sensitive.

Example usage:

type MyStruct struct {
    Field1 string `json:"field1"`
    Field2 int    `json:"field2"`
}

var obj MyStruct
err := Unmarshal([]byte(`{"field1": "value", "field2": 42}`), &obj)
if err != nil {
    log.Fatal(err)
}

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL