JSON to RDF triples

This is a test page for experimenting with automatic conversion of JSON objects to RDF triples.

The JSON source

The triples generated from the JSON source

Comments

The starting point is the URL for the root of the JSON object. This is treated as the RDF subject for one or more RDF triples. The field names for this object are interpreted as RDF predicates for these triples. The field values determine the objects for these triples. If the field value is a JSON object, the object’s field names are treated as RDF objects for the triples, and the parent field is treated as an RDF subject with the field name as RDF predicate and the value as an RDF object. This process is applied recursively if the value is itself a JSON object.

Field names are scoped by the object they are defined on. The full name of a field is determined by the path from the root. Full names are mapped to URLs using @context definitions. “@context” is a field name and the value is either a JSON object or a string literal which is assumed to be a URI for a JSON object. This object is treated as a set of name/value pairs that map field names to URLs. The field “@context” is reserved for the above use. Relative URLs are expanded to absolute URLs using the URL inherited from the nearest enclosing @context or the enclosing document.

Field values for string literals are mapped to RDF string literals. Numeric values are mapped to RDF numeric literals. NULL is treated as a special literal. Arrays are mapped to RDF sequences.

When there is a need for nested data structures for events, properties and actions, you can use "type" with an object for the nested fields. The current code doesn't deal with this properly as yet.