import "github.com/getkin/kin-openapi/jsoninfo"
Package jsoninfo provides information and functions for marshalling/unmarshalling JSON.
doc.go field_info.go marshal.go marshal_ref.go strict_struct.go type_info.go unmarshal.go unsupported_properties_error.go
func MarshalStrictStruct(value StrictStruct) ([]byte, error)
MarshalStrictStruct function:
* Marshals struct fields, ignoring MarshalJSON() and fields without 'json' tag. * Correctly handles StrictStruct semantics.
func NewUnsupportedPropertiesError(v interface{}, m map[string]json.RawMessage) error
func UnmarshalStrictStruct(data []byte, value StrictStruct) error
UnmarshalStrictStruct function:
* Unmarshals struct fields, ignoring UnmarshalJSON(...) and fields without 'json' tag. * Correctly handles StrictStruct
type FieldInfo struct { MultipleFields bool // Whether multiple Go fields share this JSON name HasJSONTag bool TypeIsMarshaller bool TypeIsUnmarshaller bool JSONOmitEmpty bool JSONString bool Index []int Type reflect.Type JSONName string }
FieldInfo contains information about JSON serialization of a field.
func NewObjectDecoder(data []byte) (*ObjectDecoder, error)
func (decoder *ObjectDecoder) DecodeExtensionMap() map[string]json.RawMessage
DecodeExtensionMap returns all properties that were not decoded previously.
func (decoder *ObjectDecoder) DecodeStructFieldsAndExtensions(value interface{}) error
type ObjectEncoder struct {
// contains filtered or unexported fields
}
func NewObjectEncoder() *ObjectEncoder
func (encoder *ObjectEncoder) Bytes() ([]byte, error)
Bytes returns the result of encoding.
func (encoder *ObjectEncoder) EncodeExtension(key string, value interface{}) error
EncodeExtension adds a key/value to the current JSON object.
func (encoder *ObjectEncoder) EncodeExtensionMap(value map[string]json.RawMessage) error
EncodeExtensionMap adds all properties to the result.
func (encoder *ObjectEncoder) EncodeStructFieldsAndExtensions(value interface{}) error
type StrictStruct interface { EncodeWith(encoder *ObjectEncoder, value interface{}) error DecodeWith(decoder *ObjectDecoder, value interface{}) error }
TypeInfo contains information about JSON serialization of a type
GetTypeInfo returns TypeInfo for the given type.
FieldNames returns all field names
type UnsupportedPropertiesError struct { Value interface{} UnsupportedProperties map[string]json.RawMessage }
UnsupportedPropertiesError is a helper for extensions that want to refuse unsupported JSON object properties.
It produces a helpful error message.
func (err *UnsupportedPropertiesError) Error() string
Package jsoninfo imports 8 packages (graph) and is imported by 8 packages. Updated 2020-09-07. Refresh now. Tools for package owners.