Checks if a value is a Resource.
Checks if a value is a Values set.
Checks if a value is a Value.
Checks if a value is a Dictionary.
Checks if a value is a Literal.
Checks if a value is a Reference.
Encodes a resource state as a JSON string.
Decodes a resource state from a JSON string.
Resource state representation.
Defines types for describing resource states and partial updates in REST/JSON APIs, using native JSON types with localised text support.
Data model
boolean,number,string)Type guards
Codecs
Resource Operations
Retrieving
A Resource is a field map describing the state of a resource:
Resources may include an IRI field mapped to
@idin the application-defined JSON-LD@context, identifying the resource globally. This field is usually namedid, but the mapping is arbitrary. A state without such a field represents an anonymous (blank) node, useful for nested structures that don't need their own identity:Resources can link to other resources using IRI references or embedded descriptions. IRI references identify a resource without describing its state, while embedded descriptions include the linked resource's properties:
Creating
A Resource serves as payload for HTTP POST operations:
Nested resource states containing properties beyond the resource identifier are only accepted if explicitly declared as embedded in the application-defined data model; non-embedded nested resources with additional properties will be rejected during validation.
Updating
A Resource also serves as payload for HTTP PUT operations:
State replacement is total: properties not included in the state are removed from the resource; empty arrays are treated as property deletions, following set semantics where an empty set is equivalent to absence.
Deleting
HTTP DELETE operations remove the resource at the request URL (no payload is required):
Value Types
Each field in a resource state holds a value set: a single scalar, a Dictionary of localised text, or an array of scalars.
A Value is a single scalar:
boolean,number,string)A Values set extends Value with collection forms:
Arrays follow set semantics: duplicates are ignored, ordering is immaterial, and empty arrays are treated as absent values, aligning with JSON-LD's multi-valued property model.
IRIs
An IRI (Internationalized Resource Identifier) is a globally unique string identifying a resource on the web. IRIs enable entity linking by referencing resources without embedding their full state. Properties mapped to
@idin the application-provided JSON-LD@contextexpect IRI values, establishing relationships between resources across systems and domains.Data structures require absolute IRIs. Codec functions (encodeResource, decodeResource) convert between absolute and internal (root-relative) forms for serialisation.
Literals
Primitive values (
boolean,number,string) map directly to JSON primitives. Dates, times, and other structured values are represented as strings in standard formats (for example, ISO 8601). Application-level@contextobjects can declare datatype coercion rules for JSON-LD processing.Dictionaries
For multilingual content, use a Dictionary. Language tags follow RFC 5646 (for example,
en,de-CH,zh-Hans):Within a single dictionary, all values must be uniformly scalar or uniformly array.
The
@nonekey for non-localised values is not supported; use theundtag for language-neutral values.See