Documentation
¶
Overview ¶
Package serde provides serialization and deserialization utilities.
It offers generic functions for JSON and YAML serialization/deserialization with type safety through Go generics.
Index ¶
- func Deserialize[T any](b []byte) (t *T, err error)
- func DeserializeArray[T any](b []byte) (a []T, err error)
- func DeserializeYAML[T any](b []byte) (t *T, err error)
- func DeserializeYAMLArray[T any](b []byte) (a []T, err error)
- func IsJSON(s string) bool
- func IsJSONArray(s string) bool
- func Serialize[T any](v T) (buf []byte, err error)
- func SerializeYAML[T any](v T) (buf []byte, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Deserialize ¶
func DeserializeArray ¶
func DeserializeYAML ¶
func DeserializeYAMLArray ¶
func IsJSON ¶
IsJSON checks whether the provided string can be unmarshal into a JSON object. It verifies that the string is not just a JSON-formatted string, but an actual JSON object. It returns true if the string is a valid JSON object, and false otherwise.
func IsJSONArray ¶
IsJSONArray checks if the provided string represents a valid JSON array. It attempts to unmarshal the string into a slice of empty interfaces. If the unmarshal is successful, the function returns true, indicating that the string is a well-formed JSON array. Otherwise, it returns false.
func SerializeYAML ¶
Types ¶
This section is empty.