SPARQL JSON-LD Encoding¶
A JSON-LD response is requested by specifying the media type
application/ld+json
as the Accept
header value along with optional arguments to indicate the context and the
expansion form.
The encoding is controlled by the optionally supplied context.
If no context is specified the elements of a default,
single-level context are generated on-demand, as term definitions
which incorporate as member names the IRI local part for
CONSTRUCT
and DESCRIBE
graph results
or the dimension names for SELECT
solution fields.
Accept
application/ld+json
: indicates that the response should be encoded as JSON-LD, as controlled by an accompanying framing context. the media type permits aprofile
argument to control the JSON-LD encoding form. it is allowed to have one of the following values:
http://www.w3.org/ns/json-ld#expanded
http://www.w3.org/ns/json-ld#compacted
(the default)
http://www.w3.org/ns/json-ld#flattened
(not the default)
Content-Type
The request body content type may indicate either a query or an update expression.
application/sparql-query
application/sparql-update
Link
A link with the relation type
http://www.w3.org/ns/json-ld#context
specifies the location of the context which is to govern the response encoding. A request to this location must permitapplication/ld+json
as theAccept
specification and must respond with a JSON-LD document which contains the context and and any framing information. In no contet link is supplied, the requisite field definitions are generated on-demand. For exampleLink: <http://json-ld.org/contexts/person.jsonld>; rel=”http://www.w3.org/ns/json-ld#context”; type=”application/ld+json”