Documentation
¶
Overview ¶
Package jsonutils provides helpers to work with JSON.
These utilities work with dynamic go structures to and from JSON.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConcatJSON ¶
ConcatJSON concatenates multiple json objects efficiently
func FromDynamicJSON ¶
func FromDynamicJSON(source, target interface{}) error
FromDynamicJSON turns a go value into a properly JSON typed structure.
"Dynamic JSON" refers to what you get when unmarshaling JSON into an untyped interface{}, i.e. objects are represented by map[string]interface{}, arrays by []interface{}, and all numbers are represented as float64.
func ReadJSON ¶
ReadJSON unmarshals JSON data into a data structure.
The difference with json.Unmarshal is that it may check among several alternatives to do so.
Currently this allows types that are [easyjson.Unmarshaler]s to use that route to process JSON.
func WriteJSON ¶
WriteJSON marshals a data structure as JSON.
The difference with json.Marshal is that it may check among several alternatives to do so.
Currently this allows types that are [easyjson.Marshaler]s to use that route to produce JSON.
Types ¶
type JSONMapItem ¶
JSONMapItem represents the value of a key in a JSON object held by JSONMapSlice.
Notice that JSONMapItem should not be marshaled to or unmarshaled from JSON directly, use this type as part of a JSONMapSlice when dealing with JSON bytes.
func (JSONMapItem) MarshalEasyJSON ¶
func (s JSONMapItem) MarshalEasyJSON(w *jwriter.Writer)
MarshalEasyJSON renders a JSONMapItem as JSON bytes, using easyJSON
func (*JSONMapItem) UnmarshalEasyJSON ¶
func (s *JSONMapItem) UnmarshalEasyJSON(in *jlexer.Lexer)
UnmarshalEasyJSON builds a JSONMapItem from JSON bytes, using easyJSON
type JSONMapSlice ¶
type JSONMapSlice []JSONMapItem
JSONMapSlice represents a JSON object, with the order of keys maintained.
func (JSONMapSlice) MarshalEasyJSON ¶
func (s JSONMapSlice) MarshalEasyJSON(w *jwriter.Writer)
MarshalEasyJSON renders a JSONMapSlice as JSON bytes, using easyJSON
func (JSONMapSlice) MarshalJSON ¶
func (s JSONMapSlice) MarshalJSON() ([]byte, error)
MarshalJSON renders a JSONMapSlice as JSON bytes, preserving the order of keys.
func (*JSONMapSlice) UnmarshalEasyJSON ¶
func (s *JSONMapSlice) UnmarshalEasyJSON(in *jlexer.Lexer)
UnmarshalEasyJSON builds a JSONMapSlice from JSON bytes, using easyJSON
func (*JSONMapSlice) UnmarshalJSON ¶
func (s *JSONMapSlice) UnmarshalJSON(data []byte) error
UnmarshalJSON builds a JSONMapSlice from JSON bytes, preserving the order of keys.
Inner objects are unmarshaled as JSONMapSlice slices and not map[string]any.