ld

package
v0.0.0-...-9de2c1c Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compact

func Compact(ctx context.Context, doc map[string]interface{}, uri string, context interface{}) (map[string]interface{}, error)

func CompactObject

func CompactObject(ctx context.Context, obj *Object) (map[string]interface{}, error)

func Expand

func Expand(ctx context.Context, doc map[string]interface{}, uri string) (map[string]interface{}, error)

func ID

func ID(id string) map[string]interface{}

Shorthand to make {"@id": v} structures.

func Is

func Is(e Entity, typ string) bool

func NewDocumentLoader

func NewDocumentLoader(ctx context.Context) ld.DocumentLoader

Returns a DocumentLoader for the json-gold library. It's basically a simplified version of the default DocumentLoader, which can't be tricked into touching the local filesystem, and with the addition of proper request contexts.

func ObjectIDs

func ObjectIDs(objs []*Object) []string

func Options

func Options(ctx context.Context, uri string) *ld.JsonLdOptions

func ToSlice

func ToSlice(raw interface{}) []interface{}

Casts to a slice. If the value is a slice, it's returned verbatim. If not, it's returned wrapped in a slice with one item.

func ToString

func ToString(raw interface{}) string

func ToStringSlice

func ToStringSlice(raw interface{}) []string

func Value

func Value(v interface{}) map[string]interface{}

Shorthand to make {"@value": v} structures.

Types

type Entity

type Entity interface {
	Obj() *Object
	IsNull() bool
	ID() string
	Value() string
	Type() []string
	Get(key string) interface{}
	Set(key string, v interface{})
	Apply(other Entity, mergeArrays bool) error
}

An interface for any kind of entity which embeds Object.

type Object

type Object struct {
	V map[string]interface{}
	// contains filtered or unexported fields
}

The base type of all JSON-LD objects.

func FetchObject

func FetchObject(ctx context.Context, id string) (*Object, error)

func NewObject

func NewObject(id string, types ...string) *Object

func ParseObject

func ParseObject(data []byte) (*Object, error)

Creates a new object from a JSON object.

func ParseObjects

func ParseObjects(data []byte) ([]*Object, error)

Creates a new list of objects from a JSON array.

func ToObject

func ToObject(raw interface{}) *Object

func ToObjects

func ToObjects(raw interface{}) []*Object

func (*Object) Apply

func (obj *Object) Apply(patch Entity, mergeArrays bool) error

Applies another object as a patch to this object. The mergeArrays argument specifies whether values for existing keys should replace the existing value, or be added as an additional value.

func (*Object) Get

func (obj *Object) Get(key string) interface{}

Nil-safe getter for attributes.

func (*Object) ID

func (obj *Object) ID() string

Returns the object's @id, or "".

func (*Object) IsNull

func (obj *Object) IsNull() bool

func (Object) MarshalJSON

func (obj Object) MarshalJSON() ([]byte, error)

func (*Object) Obj

func (obj *Object) Obj() *Object

Revolver Ocelot.

func (*Object) Set

func (obj *Object) Set(key string, value interface{})

Nil-safe setter for attributes.

func (*Object) SetID

func (obj *Object) SetID(id string)

Sets the object's @id.

func (*Object) SetType

func (obj *Object) SetType(ts ...string)

Sets the object's @type.

func (*Object) SetValue

func (obj *Object) SetValue(v string)

Sets the object's @value.

func (*Object) Type

func (obj *Object) Type() []string

Returns the object's @type, or nil.

func (*Object) UnmarshalJSON

func (obj *Object) UnmarshalJSON(data []byte) error

func (*Object) Value

func (obj *Object) Value() string

Returns the object's @value, or "".

type Source

type Source int
const (
	ClientToServer Source = iota
	ServerToServer
)

func (Source) String

func (s Source) String() string

Directories

Path Synopsis
ns
GENERATED FILE, DO NOT EDIT.
GENERATED FILE, DO NOT EDIT.
as
GENERATED FILE, DO NOT EDIT.
GENERATED FILE, DO NOT EDIT.
ldp
GENERATED FILE, DO NOT EDIT.
GENERATED FILE, DO NOT EDIT.
owl
GENERATED FILE, DO NOT EDIT.
GENERATED FILE, DO NOT EDIT.
rdf
GENERATED FILE, DO NOT EDIT.
GENERATED FILE, DO NOT EDIT.
sec
GENERATED FILE, DO NOT EDIT.
GENERATED FILE, DO NOT EDIT.

Jump to

Keyboard shortcuts

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