Flattening
The process of flattening gathers together all of the properties of a single node under a single dictionary in the output document. It also ensures that all blank nodes are labelled with a blank node identifier. A flattened document is a lot easier to process in certain applications (especially where mapping to RDF triples is desired). For more information please refer to the JSON-LD API Specification.
The Flattening operation is implemented by the static method JsonLdProcessor.Flatten(). The method accepts the following parameters:
input- the JSON-LD document to be flattened. This parameter may be either aNewtonsoft.Json.Linq.JObjectrepresenting the parsed JSON-LD document, or aNewtonsoft.Json.Linq.JValuewith a string value which is the URI of the JSON-LD document to be retrieved and processed.context- this optional parameter specifies a context to use to compact the flattened document. This parameter can be either null (in which case no compaction is performed) or one of the following values:- A
Newtonsoft.Json.Linq.JObjectrepresenting a parsed JSON-LD context - A
Newtonsoft.Json.Linq.JValuewith a string value which is the URI of the JSON-LD document to retrieve and parse - A
Newtonsoft.Json.Linq.JArrayofNewtonsoft.Json.Linq.JObjectorNewtonsoft.Json.Linq.JValueitems which represents a collection of contexts to be combined and applied to the flattened output
- A
options- aJsonLdProcessorOptionsproviding the options for the flatten and compaction (if required) operations.