types

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2025 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OrderedMap

type OrderedMap[K comparable, V any] struct {
	// contains filtered or unexported fields
}

OrderedMap preserves insertion order when marshaling/unmarshaling JSON. This ensures that JSON object keys maintain their original order rather than being alphabetically sorted during marshal operations.

func NewOrderedMap

func NewOrderedMap[K comparable, V any]() *OrderedMap[K, V]

NewOrderedMap creates a new OrderedMap.

func (*OrderedMap[K, V]) Get

func (om *OrderedMap[K, V]) Get(key K) (V, bool)

Get retrieves a value by key.

func (*OrderedMap[K, V]) JSONSchema added in v0.5.1

func (om *OrderedMap[K, V]) JSONSchema() (jsonschema.Schema, error)

JSONSchema implements the jsonschema.Exposer interface. This ensures OrderedMap is represented as a plain JSON object in schemas rather than exposing internal Go type information.

func (*OrderedMap[K, V]) Keys

func (om *OrderedMap[K, V]) Keys() []K

Keys returns all keys in insertion order.

func (*OrderedMap[K, V]) Len

func (om *OrderedMap[K, V]) Len() int

Len returns the number of key-value pairs.

func (*OrderedMap[K, V]) MarshalJSON

func (om *OrderedMap[K, V]) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler, writing keys in insertion order.

func (*OrderedMap[K, V]) Range

func (om *OrderedMap[K, V]) Range(fn func(key K, value V) bool)

Range iterates over the map in insertion order.

func (*OrderedMap[K, V]) Set

func (om *OrderedMap[K, V]) Set(key K, value V)

Set stores a value with the given key, preserving insertion order.

func (*OrderedMap[K, V]) UnmarshalJSON

func (om *OrderedMap[K, V]) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler, preserving key order.

Jump to

Keyboard shortcuts

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