Documentation
¶
Index ¶
- func SomeGraphFromJSONable(value interface{}, ref string, target *SomeGraph, errors *Errors)
- func SomeGraphToJSONable(instance *SomeGraph) (target map[string]interface{}, err error)
- func WithOptionalFromJSONable(value interface{}, id string, ref string, target *WithOptional, errors *Errors)
- func WithOptionalToJSONable(instance *WithOptional) (target map[string]interface{})
- type Error
- type Errors
- type SomeGraph
- type WithOptional
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SomeGraphFromJSONable ¶
SomeGraphFromJSONable parses SomeGraph from a JSONable value.
If there are any errors, the state of target is undefined.
SomeGraphFromJSONable requires:
- target != nil
- errors != nil
- errors.Empty()
func SomeGraphToJSONable ¶
SomeGraph converts the instance to a JSONable representation.
SomeGraph requires:
- instance != nil
SomeGraph ensures:
- (err == nil && target != nil) || (err != nil && target == nil)
func WithOptionalFromJSONable ¶
func WithOptionalFromJSONable( value interface{}, id string, ref string, target *WithOptional, errors *Errors)
WithOptionalFromJSONable parses WithOptional from a JSONable value.
If there are any errors, the state of the target is undefined.
WithOptionalFromJSONable requires:
- target != nil
- errors != nil
- errors.Empty()
func WithOptionalToJSONable ¶
func WithOptionalToJSONable( instance *WithOptional) ( target map[string]interface{})
WithOptionalToJSONable converts the instance to a JSONable representation.
WithOptionalToJSONable requires:
- instance != nil
WithOptionalToJSONable ensures:
- target != nil
Types ¶
type Error ¶
type Error struct { // references the cause (e.g., a reference path). Ref string // describes the error. Message string }
Error represents a parsing error.
type Errors ¶
type Errors struct {
// contains filtered or unexported fields
}
Errors collects parsing errors capped at a certain quantity.
If the capacity is full, the subsequent surplus errors are ignored.
func NewErrors ¶
NewErrors initializes a new error container with the capacity `cap`.
The capacity of 0 means infinite capacity.
func (*Errors) Add ¶
Add inserts the error into the container.
ref indicates the cause (e.g., as a reference path). message describes the error. If the capacity is full, the subsequent surplus errors are ignored.
type SomeGraph ¶
type SomeGraph struct { // registers instances of WithOptional. WithOptionals map[string]*WithOptional }
SomeGraph defines some object graph.
type WithOptional ¶
type WithOptional struct { // identifies the instance ID string // defines an optional property. SomeText *string }
WithOptional defines a class with an optional property.