json

package
v0.0.0-...-986c4a6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 17, 2020 License: MIT Imports: 11 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Deserialize

func Deserialize(json []byte, resource *prop.Resource) error

Entry point of JSON deserialization. Unmarshal the JSON input bytes into the unassigned structure of resource.

func DeserializeProperty

func DeserializeProperty(json []byte, property prop.Property, allowElementForArray bool) error

Entry point to deserialize a piece of JSON data into the given property. The JSON data is expected to be the content of a json.RawMessage parsed from the built-in encoding/json mechanism, hence, it should not contain any preceding spaces, and should a fragment of valid JSON. The allowElementForArray option is provided to allow JSON array element values be provided for a multiValued property so that it will be de-serialized as its element. The result will be a multiValued property containing a single element.

func Options

func Options() *options

Create a new empty JSON serialization option.

func Serialize

func Serialize(resource *prop.Resource, options *options) ([]byte, error)

Serialize the given resource to JSON bytes.

func Valid

func Valid(data []byte) bool

Valid reports whether data is a valid JSON encoding.

Types

type ResourceMarshalAdapter

type ResourceMarshalAdapter struct {
	Resource *prop.Resource
	Include  []string
	Exclude  []string
}

func (ResourceMarshalAdapter) MarshalJSON

func (r ResourceMarshalAdapter) MarshalJSON() ([]byte, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL