Decodes a resource state from a JSON string.
If base is provided, resolves internal IRIs (matching isIRI(value, "internal")) to absolute IRIs using resolve(), recursively throughout the json structure. Otherwise, performs plain JSON parsing.
base
isIRI(value, "internal")
resolve()
The JSON-serialized Resource
Decoding options
The decoded resource, with resolved IRIs if base is provided
If json is not a string, not a valid Resource, or opts is not a valid CodecOpts
json
opts
decodeResource( '{"id":"/products/42","name":"Widget","price":29.99}', { base: "https://example.com/" });// → { id: "https://example.com/products/42", name: "Widget", price: 29.99 } Copy
decodeResource( '{"id":"/products/42","name":"Widget","price":29.99}', { base: "https://example.com/" });// → { id: "https://example.com/products/42", name: "Widget", price: 29.99 }
encodeResource
Decodes a resource state from a JSON string.
If
baseis provided, resolves internal IRIs (matchingisIRI(value, "internal")) to absolute IRIs usingresolve(), recursively throughout the json structure. Otherwise, performs plain JSON parsing.