LInked Object Notation · a subset of JSON-LD

JSON objects with a URL for a name.

A Linked Object is an object you fetch from a URL, with the URL as its identifier. Give an object an @id and it can be pointed at, updated on its own, and reused anywhere. That is the whole idea, and it is still plain JSON.

Valid JSON-LD 1.1, without the ceremony: no context to fetch, no vocabulary to pick first. Add them later if you need RDF.

two objects, one link
GET /people/john.json{ "@id": "/people/john.json", "name": "John Lennon", "born": "1940-10-09", "spouse": "/people/cynthia.json" }
GET /people/cynthia.json{ "@id": "/people/cynthia.json", "name": "Cynthia Lennon" }
In short Plain JSON URLs as identifiers No context required Upgrade path to JSON-LD and RDF

Why linked objects

Nesting copies data. Linking points at it.

When an object lives inside another, every copy has to be kept in step. When it has its own URL, there is one of it, and everything else refers to it.

Simpler handling

Refer to an object by its URL instead of carrying it around. Code that manages nested data gets shorter and clearer.

Independent updates

Change one object without touching the ones that point at it. Nothing else has to be rewritten.

Reuse

The same object can appear in many places, because each place holds a reference and not a copy.

JSON-LD compatible

Every LION document is JSON-LD. Start simple, and add a context when you want the full linked-data toolchain.

Linked Object Notation

LION: three keywords, all optional.

LION is a small subset of JSON-LD, chosen to leave out most of its complexity. If you can write JSON you can write LION. Full details of the keywords are in the JSON-LD specification.

@id

the name

The URL of the object

Absolute or relative, and may be written id. Optional but recommended: it is what makes an object a Linked Object.

@type

the kind

What sort of thing it is

May be written type, and normally maps to a URL. Optional.

@context

the upgrade

Names mapped to URLs

Optional. Add it for full JSON-LD. Without one, processors that need RDF read bare property names against the default vocabulary urn:solid:.

application/ld+json
{
  "@id": "http://dbpedia.org/resource/John_Lennon",
  "name": "John Lennon",
  "born": "1940-10-09",
  "spouse": "http://dbpedia.org/resource/Cynthia_Lennon"
}

The library

Six functions for working with them.

A small JavaScript library for creating, finding and updating Linked Objects in memory, wherever they sit in a nested structure, and for moving them in and out of JSON.

install
npm install linkedobjects
import
import {
  create, fetch, update,
  deleteObject, importJSON, exportJSON
} from 'linkedobjects'
API referenceobjects = your container
FunctionWhat it does
create(objects, id, data)Creates a Linked Object with that id and data, and returns it.
fetch(objects, id)Finds the object with that id, however deeply nested. Returns it, or null.
update(objects, id, data)Merges new data into the object with that id. Returns it, or null.
deleteObject(objects, id)Removes the object with that id. Returns true if it was deleted.
importJSON(objects, json)Reads Linked Objects from a JSON string into the container.
exportJSON(objects)Writes the container's Linked Objects out as a JSON string.
See every function running in the interactive demo.

Background

Where it comes from.

The idea of naming JSON objects with URLs is older than JSON-LD. LION keeps that core and leaves the rest optional.

Give an object an @id and see what it can do.

Try the functions in your browser, or read the specification and the source. Issues and contributions are welcome.