Shape Your Linked Data with JSON-LD Framing
The Twinfox platform now lets you query and transform a subset of your hypergraph data into accurate structured JSON-LD documents.
What is JSON-LD Framing?
JSON-LD is a popular format for representing linked data as JSON objects. It allows you to express the semantics and structure of your data using a context with prefixes and additional information on how to interpret the graph.
The context defines the meaning of the terms and properties used in your data, while the prefixes map the terms used in the JSON document with their definitions, expressed as corresponding vocabulary or ontologies. For example, you can use the context and prefixes to specify that your data follows the schema.org vocabulary, or that it uses the Dublin Core terms for metadata.
Whilst the Twinfox platform enables strong control and guards that your data is always structured correctly, JSON-LD does not impose any restrictions on how you organize your data within the JSON objects. You can have different shapes and layouts for the same data, depending on how you nest, group, or flatten the objects. This can make it hard to query, filter, sort, or transform your data, especially if you want to extract a specific subset or view of your data for use in a system that expects the information in a different shape.
This is where JSON-LD framing comes in. JSON-LD framing is a way of specifying the shape and content of a subset (or complete) linked data hypergraph that you want to retrieve as JSON-LD documents. You can use a JSON-LD frame to define the structure, properties, values, and ordering of the objects in your desired output. The frame acts as a template or a filter that matches and transforms your data into the desired shape.
Why Use JSON-LD Framing?
JSON-LD framing can be useful for many scenarios where you want to manipulate or present your linked data in a specific way. For example, you can use JSON-LD framing to:
- Filter out irrelevant or redundant data and only keep the properties and values that you need.
- Sort your data by one or more properties, such as date, name, or rating.
- Nest or flatten your data to create hierarchical or flat structures, depending on your needs.
- Group your data by a common property, such as type, category, or location.
- Transform your data into a different vocabulary or ontology, by mapping the terms and prefixes in your frame to the ones in your target schema.
- Transform your linked data product structure to include additional interlinked related documents when extracting a set of information
- Extract information in a specific format
- Create custom views and presentations of your data, such as tables, charts, or graphs.
JSON-LD framing can also help you ensure consistency and compatibility of your data across different systems and applications. By using a common frame, you can make sure that your data has the same shape and meaning, ensuring that you can store a perfect golden record and convert it into the shape that other systems need.
How to Use JSON-LD Framing with Twinfox?
The Twinfox Hypergraph platform is a linked data management solution developed by DFRNT that includes an easy-to-use web user interface for working with structured information. It is used by many teams to provide portable model-based linked data product experiences to their users.
The Twinfox Studio lets you store, query, and process your linked data as a directed hypergraph, a powerful data structure that can represent complex and dynamic relationships between your information objects, and where lists, sets and multi-dimensional arrays of objects can be linked through properties.
The Twinfox platform uses JSON-LD as the native format for exchanging business information. You can use JSON-LD to define the context and prefixes of your data so all structural identifiers can be recognized globally and across organisations, as well as the structure and values of your objects. The Twinfox platform will automatically guard, validate and index your data according to the information model of the linked data product which can be exported as JSON-LD schema for validation in other systems too.
Now, Twinfox also supports JSON-LD framing as a new feature for querying your hypergraph and getting the results in a structured and consistent format. To use this feature, simply enter your JSON-LD frame in the JSON-LD query frame editor that is found in under Manage > Export of your linked data product and run it to extract a portion of the graph back.
Here is an example of how to use JSON-LD framing in the Twinfox Studio. Suppose you want to extract a set of Blogposts from your hypergraph and include the separate linked author that is an independent record of type Person. The way to do it is to help the JSON-LD frame interpreter to say we want to treat the author as a thing and not just the id of an IRI string. We copied the id:s of two blogposts to extract (omit “@id” to get all of them). You can use the following JSON-LD frame to extract them, and expand the author object:
The resulting frame will match the specified blogposts in the linked data product hypergraph and also pick up the associated author Person object. All IDs used in the linked data products are full global content-addressable IRIs according to the Resource Description Framework, but as we use JSON-LD and the built-in context of the linked data product, we don’t need to specify them, and the query result will include the context for them as we can see in the screenshot below.
Notice that author has been expanded, and that the record is of the Person type. Frontmatter is a subrecord directly attached to the Blogpost record, whereas the Person document is an independent object.
Unpacking the framed result
Now that sentence was probably quite a bit to unpack so let’s do it together.
Twinfox Studio manages structured information stored in a linked data product, that is organised as a directed hypergraph, in this context it simply means that we can have sets and lists attached to a property.
The Twinfox platform stores objects, which can be seen as collections of triples that belong together. They are created, updated and deleted as one object. Objects can contain one record, or it can contain a record with nested subrecords. Each record conforms to a type or trait (subtype) that is well-defined as part of the information model for the linked data product.
The Frontmatter subrecord that is attached to the Blogpost will be deleted and updated as part of updating the Blogpost. The Blogpost object with the specific id contains both the Blogpost record and the Frontmatter subrecord.
In traditional knowledge graphs, each triple is independent from every other triple, even if they are linked. In Twinfox they are objects, complex sets of information with a “shared lifecycle”, living together from birth to death and that awkward moment in-between.
The Person object is an independent object from the Blogpost object, and are linked via the “author” property/predicate of Frontmatter which is part of Blogpost. The link can be either unresolved (the default in a JSON-LD frame) so that the ID of the author is returned as a string, or when specified in the @context to be of type “@id”, it is resolved by the hypergraph engine and returned as part of the result.
As you can see, JSON-LD framing is a powerful and flexible way of shaping your linked data product processed through the Twinfox platform. You can use it to create custom views and presentations of your data, as well as to ensure consistency and compatibility across different systems and applications. You can also use it to transform your data into different vocabularies or ontologies, by changing the context and prefixes in your frame.
Conclusion
JSON-LD framing is a new feature of the Twinfox platform that lets you query and transform your hypergraph data into structured JSON-LD documents and is available through the Twinfox Studio. You can use JSON-LD frames to shape the content of your linked data product to suit your content needs. This feature is useful for structuring your graph objects as needed, as well as for creating custom views and representations of your structured information objects.
If you want to learn more about JSON-LD framing and how to use it with the Twinfox Studio, sign up for a free trial today. Twinfox is a hypergraph platform developed by DFRNT to enable cross-organisational linked data product collaboration.
It is used by many teams to provide portable model-based linked data product experiences to their users. Twinfox Studio lets you store, query, and process your linked data as a hypergraph, a powerful data structure that can represent complex and dynamic relationships between structured information objects.
With DFRNT Twinfox, you can revolutionize your business information management and drive your competitive advantage. Twinfox is the linked data product platform enabling tech-savvy entrepreneurs to build solutions that drive their companies’ competitive edge.