json

package
v2.2.6 Latest Latest
Warning

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

Go to latest
Published: May 16, 2023 License: MIT Imports: 11 Imported by: 0

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

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

Deserialize is the entry point of JSON deserialization. Unmarshal the JSON input bytes into a pre-prepared 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 Serialize

func Serialize(serializable Serializable, options ...Options) ([]byte, error)

Serialize the given resource to JSON bytes. The serialization process subjects to the request attributes and excludedAttributes from options, and the SCIM return-ability rules.

Types

type Options

type Options interface {
	// contains filtered or unexported methods
}

JSON serialization options.

func Exclude

func Exclude(attributes ...string) Options

Exclude returns Options to exclude given attributes in JSON serialization. Supplied attributes are still subject to SCIM rules for return-ability.

func Include

func Include(attributes ...string) Options

Include returns Options to include given attributes in JSON serialization. Supplied attributes are still subject to SCIM rules for return-ability.

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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