Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func UnmarshalSlice ¶
UnmarshalSlice is a function that parses JSON data into a slice of the provided interface. It handles the case where the input data is not a JSON array by wrapping it in an array.
Examples:
data := []byte(`{"name": "Bob"}`) var result []map[string]any err := UnmarshalSlice(data, &result) // result is now [{"name": "Bob"}] data := []byte(`{"name": "Bob"}`) var result []map[string]string err := UnmarshalSlice(data, &result) // result is now [{"name": "Bob"}] data := []byte(`{"name": "Bob"}`) var result []any err := UnmarshalSlice(data, &result) // result is now [{"name": "Bob"}] data := []byte(`{"name": "Bob"}`) var result []map[string]string err := UnmarshalSlice(data, &result) // result is now [{"name": "Bob"}] // NOTE: if the input data is not a JSON array, it is wrapped in an array before decoding
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.