Skip to content
This repository has been archived by the owner on Sep 8, 2023. It is now read-only.

Latest commit

 

History

History
16 lines (12 loc) · 1.75 KB

JsonLd-Compaction.md

File metadata and controls

16 lines (12 loc) · 1.75 KB

Compaction

Compaction is the opposite to Expansion. The compaction process applies a context to a JSON-LD document and uses it to shorten IRIs to terms or CURIES and compress JSON-LD values to simple strings or numbers. For more information please refer to the JSON-LD API Specification.

The Compaction operation is implemented through the static method JsonLdProcessor.Compact (and in the .NET Standard framework the asynchronous JsonLdProcessor.CompactAsync method). This method accepts three parameters:

  • input - a Newtonsoft.Json.Linq.JToken that represents the input document to be processed or the URI of the document to be retrieved and processed. The input may be one of the following types:
    • A JObject representing a parsed JSON-LD document
    • A JValue with a string value which is the URI of the JSON-LD document to retrieve and parse
  • context - a Newtonsoft.Json.Linq.JToken that represents the context to be applied to the input document. The context value may be one of the following types:
    • A JObject representing a parsed JSON-LD context
    • A JValue with a string value which is the URI of the JSON-LD document to retrieve and parse
    • A JArray of JObject or JValue items which represents a collection of contexts to be combined and applied to the input document.
  • options - a JsonLdProcessorOptions instance providing the options for the compaction operation.

The output of the method is a Newtonsoft.Json.Linq.JObject that represents the compacted JSON-LD document.