package
1.0.33
Repository: https://github.com/eluv-io/common-go.git
Documentation: pkg.go.dev

# Functions

Clone clones the given data structure by marshaling it to JSON and unmarshaling it back from JSON.
GetJsonFields extracts the field names of the given struct type just like the json library does using 'json' struct tags.
IsJson checks whether the given byte slice is a valid JSON document.
Marshal marshals the given value as indented JSON and returns it as a byte slice.
MarshalCompact marshals the given value as compact JSON (no indenting, no newlines) and returns it as a byte slice.
MarshalCompactString marshals the given value as compact JSON (no indenting, no newlines) and returns it as a string.
MarshallingError converts the given marshalling error to a string in JSON format limited to ~100 characters.
MarshalString marshals the given value as indented JSON and returns it as a string.
MustClone clones the given data structure by marshaling it to JSON and unmarshaling it back from JSON.
MustPretty parses the given json string and re-marshals it in "pretty" format with line breaks and indentation.
ParseJsonTag parses the given struct tag and determines whether it contains a JSON key, the JSON name and the squash flag (defined by the mapstructure lib).
Pretty parses the given json string and re-marshals it in "pretty" format with line breaks and 2-space indentation.
SetDefaults copies the default values to the given target struct.
Stringer returns a wrapper around val whose String() function will simply return val's JSON representation.
ToFieldTracker converts the given map to a FieldTracker.
Unmarshal unmarshals the given JSON byte slice into v.
UnmarshalString unmarshals the given JSON string into v.
UnmarshalStringToAny unmarshals the given JSON string into an empty interface.
UnmarshalStringToMap unmarshals the given JSON string into a new map.
UnmarshalToAny unmarshals the given JSON byte slice into an empty interface.
UnmarshalToMap unmarshals the given JSON byte slice into a new map.

# Interfaces

GenericMarshaler is an interface for types that implement a marshalling method which converts the type to a generic go data structure consisting of map[string]interface{}, []interface{} and primitive types.

# Type aliases

FieldTracker is a map that can be used to track which fields (keys) in a JSON object (map) are set.