Documentation
¶
Overview ¶
This package implements direct JSON serializing and de-serializing for Property and Resource.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Deserialize ¶
Deserialize is the entry point of JSON deserialization. Unmarshal the JSON input bytes into a pre-prepared unassigned structure of Resource.
func DeserializeProperty ¶
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.
Types ¶
type Options ¶
type Options interface {
// contains filtered or unexported methods
}
JSON serialization options.
type Serializable ¶
type Serializable interface { // MainSchemaId returns the id of the resource type's main schema that describes the target MainSchemaId() string // Visit implements the order for the visitor Visit(visitor prop.Visitor) error }
Interface to implement to be able to serialize to JSON.
func ResourceTypeToSerializable ¶
func ResourceTypeToSerializable(resourceType *spec.ResourceType) Serializable
ResourceTypeToSerializable returns a Serializable wrapper for a resource type so it can be used to call json.Serialize
func SchemaToSerializable ¶
func SchemaToSerializable(sch *spec.Schema) Serializable
SchemaToSerializable returns a Serializable wrapper for a schema so it can be used to call json.Serialize