serde

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2026 License: MIT Imports: 2 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Deserialize

func Deserialize[T any](b []byte) (t *T, err error)

func DeserializeArray

func DeserializeArray[T any](b []byte) (a []T, err error)

func DeserializeYAML

func DeserializeYAML[T any](b []byte) (t *T, err error)

func DeserializeYAMLArray

func DeserializeYAMLArray[T any](b []byte) (a []T, err error)

func IsJSON

func IsJSON(s string) bool

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

func IsJSONArray(s string) bool

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 Serialize

func Serialize[T any](v T) (buf []byte, err error)

func SerializeYAML

func SerializeYAML[T any](v T) (buf []byte, err error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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