Documentation
¶
Index ¶
- func DropElement(extension []byte, elementNames ...string) ([]byte, error)
- func FindElement(extension []byte, elementNames ...string) (bool, int64, int64, error)
- func Marshal(v interface{}) ([]byte, error)
- func MergeClone(v any, data json.RawMessage) error
- func Unmarshal(data []byte, v interface{}) error
- func UnmarshalValid(data []byte, v interface{}) error
- type RawMessageExtension
- type StringInt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DropElement ¶
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 ¶
Finds element in json byte array with any level of nesting
func Marshal ¶
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 ¶
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 ¶
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