Encodes a patch as a JSON string.
If base is provided, converts absolute IRIs (matching isIRI(value, "absolute")) to internal IRIs using internalize, recursively throughout the patch structure. Otherwise, performs plain JSON serialization.
base
isIRI(value, "absolute")
The patch to encode
Encoding options
The JSON string, with internalized IRIs if base is provided
If patch is not a valid Patch or opts is not a valid CodecOpts
patch
opts
encodePatch( { vendor: "https://example.com/vendors/acme", description: null }, { base: "https://example.com/" });// → '{"vendor":"/vendors/acme","description":null}' Copy
encodePatch( { vendor: "https://example.com/vendors/acme", description: null }, { base: "https://example.com/" });// → '{"vendor":"/vendors/acme","description":null}'
decodePatch
Encodes a patch as a JSON string.
If
baseis provided, converts absolute IRIs (matchingisIRI(value, "absolute")) to internal IRIs using internalize, recursively throughout the patch structure. Otherwise, performs plain JSON serialization.