jsonutil

package
v2.27.1 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DropElement

func DropElement(extension []byte, elementNames ...string) ([]byte, error)

Drops element from json byte array - Doesn't support drop element from json list - Keys in the path can skip levels - First found element will be removed

func FindElement

func FindElement(extension []byte, elementNames ...string) (bool, int64, int64, error)

Finds element in json byte array with any level of nesting

func Marshal

func Marshal(v interface{}) ([]byte, error)

Marshal marshals a data structure into a byte slice without performing any validation on the data. A marshal error is returned if a non-validation error occurs.

func MergeClone added in v2.16.0

func MergeClone(v any, data json.RawMessage) error

MergeClone unmarshals json data on top of an existing object and clones pointers of the existing object before setting new values. Slices and maps are also cloned. Fields of type json.RawMessage are merged rather than replaced.

func Unmarshal

func Unmarshal(data []byte, v interface{}) error

Unmarshal unmarshals a byte slice into the specified data structure without performing any validation on the data. An unmarshal error is returned if a non-validation error occurs.

func UnmarshalValid

func UnmarshalValid(data []byte, v interface{}) error

UnmarshalValid validates and unmarshals a byte slice into the specified data structure returning an error if validation fails

Types

type RawMessageExtension added in v2.9.0

type RawMessageExtension struct {
	jsoniter.DummyExtension
}

RawMessageExtension will call json.Compact() on every json.RawMessage field when getting marshalled.

func (*RawMessageExtension) CreateEncoder added in v2.9.0

func (e *RawMessageExtension) CreateEncoder(typ reflect2.Type) jsoniter.ValEncoder

CreateEncoder substitutes the default jsoniter encoder of the json.RawMessage type with ours, that calls json.Compact() before writting to the stream

type StringInt

type StringInt int

func (*StringInt) UnmarshalJSON

func (st *StringInt) UnmarshalJSON(b []byte) error

Jump to

Keyboard shortcuts

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