Documentation ¶
Overview ¶
Package json provide functions for marshalling an unmarshalling types to JSON. These functions are meant to be utilized inside of structs that implement json.Unmarshaler and json.Marshaler interfaces. This package provides the additional functionality of writing fields that are not in the struct when marshalling to a field called AdditionalFields if that field exists and is a map[string]interface{}. When marshalling, if the struct has all the same prerequisites, it will uses the keys in AdditionalFields as extra fields. This package uses encoding/json underneath.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Marshal ¶
Marshal is used to marshal a type into its JSON representation. It wraps the stdlib calls in order to marshal a struct or *struct so that a field called "AdditionalFields" of type map[string]interface{} with "-" used inside struct tag `json:"-"` can be marshalled as if they were fields within the struct.
func MarshalRaw ¶
func MarshalRaw(i interface{}) json.RawMessage
MarshalRaw marshals i into a json.RawMessage. If I cannot be marshalled, this will panic. This is exposed to help test AdditionalField values which are stored as json.RawMessage.
Types ¶
This section is empty.