API Docs for: 1.3.12
Show:

EcLinkedData Class

Represents a JSON-LD linked data object and performs serialization. Note: Serialization and deserialization remove parameters that begin with '@'. Note: This Linked Data Object is not assumed to have an @id field.

Methods

atIfy

() Object

Forces Javascript to encode the object in alphabetical order in order to make signature based actions more viable. Also places @(at) symbols in front of appropriate fields.

Returns:

Object:

Serializable JSON object.

copyFrom

(
  • that
)

Also could be called "upcast", for those in the know.

Ghetto method of copying properties from some other object. As freshly deserialized javascript objects do not inherently attach the functions of their type, it is this or factory hell.

Parameters:

  • that Object

    The freshly deserialized object, or the object to upcast into this object.

deAtify

() EcLinkedData

Removes the @ symbol from properties in order to make them more accessible in Javascript.

Returns:

EcLinkedData:

This object, with @ properties converted to @-less properties.

getFullType

() String

Gets the fully qualified type name, as JSON-LD allows the "namespace" of the type to be defined in @context.

Returns:

String:

Fully qualified type name.

getTypes

() String

Gets all versions of JSON-LD type strings for this type of object.

Returns:

String:

Array of URIs.

isA

(
  • type
)
Boolean

Uses the object's fully qualified type name and compares it to the provided type.

Parameters:

  • type String

    Fully qualified type name uri.

Returns:

Boolean:

True if match, False if not.

isAny

(
  • type
)
Boolean

Uses the object's fully qualified type name and compares it to the provided type.

Parameters:

  • type String

    Fully qualified type name uris.

Returns:

Boolean:

True if match, False if not.

isAtProperty

(
  • key
)
Boolean static

Determines which fields to serialize into @fields.

Parameters:

  • key String

    Property name to check if it should be an @property.

Returns:

Boolean:

True if property is in the set of atProperties.

isProbablyJson

(
  • probableJson
)
Boolean static

Helper function to determine if a piece of data is probably a JSON object.

Parameters:

  • probableJson String

    JSON to test.

Returns:

Boolean:

True if it is probably JSON. False if not.

setContextAndType

(
  • context
  • type
)

Set the JSON-LD @context and @type.

Parameters:

  • context String

    JSON-LD Context.

  • type String

    JSON-LD Type.

toJson

() String

Serializes this object to JSON.

Returns:

String:

JSON formatted object (with JSON-LD fields).

upgrade

()

Upgrades the object to the latest version, performing transforms and the like.

Properties

context

String

JSON-LD @context field.

type

String

JSON-LD @type field.