kin-openapi: Index | Files

package jsoninfo

import ""

Package jsoninfo provides information and functions for marshalling/unmarshalling JSON.


Package Files

doc.go field_info.go marshal.go marshal_ref.go strict_struct.go type_info.go unmarshal.go unsupported_properties_error.go

func MarshalRef Uses

func MarshalRef(value string, otherwise interface{}) ([]byte, error)

func MarshalStrictStruct Uses

func MarshalStrictStruct(value StrictStruct) ([]byte, error)

MarshalStrictStruct function:

* Marshals struct fields, ignoring MarshalJSON() and fields without 'json' tag.
* Correctly handles StrictStruct semantics.

func NewUnsupportedPropertiesError Uses

func NewUnsupportedPropertiesError(v interface{}, m map[string]json.RawMessage) error

func UnmarshalRef Uses

func UnmarshalRef(data []byte, destRef *string, destOtherwise interface{}) error

func UnmarshalStrictStruct Uses

func UnmarshalStrictStruct(data []byte, value StrictStruct) error

UnmarshalStrictStruct function:

* Unmarshals struct fields, ignoring UnmarshalJSON(...) and fields without 'json' tag.
* Correctly handles StrictStruct

type FieldInfo Uses

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 AppendFields Uses

func AppendFields(fields []FieldInfo, parentIndex []int, t reflect.Type) []FieldInfo

type ObjectDecoder Uses

type ObjectDecoder struct {
    Data []byte
    // contains filtered or unexported fields

func NewObjectDecoder Uses

func NewObjectDecoder(data []byte) (*ObjectDecoder, error)

func (*ObjectDecoder) DecodeExtensionMap Uses

func (decoder *ObjectDecoder) DecodeExtensionMap() map[string]json.RawMessage

DecodeExtensionMap returns all properties that were not decoded previously.

func (*ObjectDecoder) DecodeStructFieldsAndExtensions Uses

func (decoder *ObjectDecoder) DecodeStructFieldsAndExtensions(value interface{}) error

type ObjectEncoder Uses

type ObjectEncoder struct {
    // contains filtered or unexported fields

func NewObjectEncoder Uses

func NewObjectEncoder() *ObjectEncoder

func (*ObjectEncoder) Bytes Uses

func (encoder *ObjectEncoder) Bytes() ([]byte, error)

Bytes returns the result of encoding.

func (*ObjectEncoder) EncodeExtension Uses

func (encoder *ObjectEncoder) EncodeExtension(key string, value interface{}) error

EncodeExtension adds a key/value to the current JSON object.

func (*ObjectEncoder) EncodeExtensionMap Uses

func (encoder *ObjectEncoder) EncodeExtensionMap(value map[string]json.RawMessage) error

EncodeExtensionMap adds all properties to the result.

func (*ObjectEncoder) EncodeStructFieldsAndExtensions Uses

func (encoder *ObjectEncoder) EncodeStructFieldsAndExtensions(value interface{}) error

type StrictStruct Uses

type StrictStruct interface {
    EncodeWith(encoder *ObjectEncoder, value interface{}) error
    DecodeWith(decoder *ObjectDecoder, value interface{}) error

type TypeInfo Uses

type TypeInfo struct {
    Type   reflect.Type
    Fields []FieldInfo

TypeInfo contains information about JSON serialization of a type

func GetTypeInfo Uses

func GetTypeInfo(t reflect.Type) *TypeInfo

GetTypeInfo returns TypeInfo for the given type.

func GetTypeInfoForValue Uses

func GetTypeInfoForValue(value interface{}) *TypeInfo

func (*TypeInfo) FieldNames Uses

func (typeInfo *TypeInfo) FieldNames() []string

FieldNames returns all field names

type UnsupportedPropertiesError Uses

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 (*UnsupportedPropertiesError) Error Uses

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.