JSON-LD (JavaScript Object Notation for Linked Data) is a data format that extends JSON to create machine-readable linked data while maintaining human readability. Unlike standard JSON, JSON-LD introduces special semantic properties like "@context" (which maps properties to IRIs), "@type" (defining object types), and "@id" (providing unique identifiers). These additions enable JSON-LD to create standardized, semantic connections between data points while remaining compatible with existing JSON tooling.
The key difference between JSON and JSON-LD lies in the semantic layer JSON-LD provides.
Consider a simple JSON object:
{
"name": "John Doe",
"jobTitle": "Professor"
}
The equivalent in JSON-LD would be:
{
"@context": {
"name": "http://schema.org/name",
"jobTitle": "http://schema.org/jobTitle"
},
"@type": "Person",
"name": "John Doe",
"jobTitle": "Professor"
}
This semantic layer allows machines to understand not just the structure but the meaning of the data by linking properties to shared vocabularies.
JSON-LD serves multiple purposes, with its primary applications being in semantic web development, search engine optimization (SEO), data integration, and knowledge graph construction. For SEO, it helps search engines better understand web content and provide rich results. In data integration, it enables combining information from multiple sources by standardizing property definitions. For knowledge graphs, it provides a framework for connecting different pieces of information in meaningful ways.
More recently, JSON-LD has been adapted for AI training formats, particularly in fine-tuning language models. In this context, it provides a structured way to represent training data, conversations, and instructions along with their metadata.
A typical AI training example might look like:
{
"@context": {
"type": "fine-tuning/conversation"
},
"messages": [
{
"role": "human",
"content": "What is quantum computing?"
},
{
"role": "assistant",
"content": "Quantum computing uses quantum mechanics..."
}
],
"metadata": {
"task_type": "explanation",
"domain": "physics"
}
}
This adaptation maintains the benefits of JSON-LD's structured approach while simplifying it for machine learning applications.