Recommended mimetype for JSON-LD payload?

1,633 views
Skip to first unread message

ogrisel

unread,
Oct 25, 2010, 5:38:13 AM10/25/10
to json-ld
Hi all,

First thanks for taking the initiative to publish such a beautiful
spec! IMHO this was missing to make the semantic web leave the ivory
towers of academics and spread on the webapp dev communities.

Here is my question: often when you query a RDF oriented application
the serialisation format of the response is negotiated according to
the content of the "Accept" HTTP header. The same holds hold for
POST / PUT request with the "Content-Type" HTTP header.

Is there a recommended mimetype for json ld payloads?

If not, would "application/json+ld" be a good option for instance?

Best,

--
Olivier

Bradley Allen

unread,
Oct 25, 2010, 9:17:20 AM10/25/10
to jso...@googlegroups.com
I've been assuming that application/json would suffice, per RFC 4627.
I think this would be even more the case if the ambition of JSON-LD is
to provide a way to semanticize arbitrary JSON. - cheers, BPA

Bradley P. Allen
Gmail: bradleypallen
Twitter: bradleypallen
Web: bradleypallen.org
Cell: +1 424 634 0870

Fabian Christ

unread,
Oct 25, 2010, 9:32:47 AM10/25/10
to jso...@googlegroups.com
Hi,

first let me also thank and congratulate you to this nice spec!

Now I had a look at RFC 4627 which states:

"4. Parsers

A JSON parser transforms a JSON text into another representation. A
JSON parser MUST accept all texts that conform to the JSON grammar.
A JSON parser MAY accept non-JSON forms or extensions."

Now json-ld is an extension of json and any JSON parser may understand
the extension or not. But don't we need a mime-type to describe that we
want a parser which is able to understand json-ld?

Or is the plan to completely replace old JSON with json-ld?

Best,
Fabian

Olivier Grisel

unread,
Oct 25, 2010, 9:57:20 AM10/25/10
to jso...@googlegroups.com
2010/10/25 Bradley Allen <bradley...@gmail.com>:

> I've been assuming that application/json would suffice, per RFC 4627.
> I think this would be even more the case if the ambition of JSON-LD is
> to provide a way to semanticize arbitrary JSON. - cheers, BPA

Ok for "application/json" as a first step (let see what happens). At
the very least least one should take care not to reuse the
"application/rdf+json" mimetype that is used by the verbose RDF/JSON
spec [1] that is already deployed in applications such as Apache
Clerezza and RDFQuery [2]

[1] http://n2.talis.com/wiki/RDF_JSON_Specification
[2] http://code.google.com/p/rdfquery/wiki/RdfPlugin

By the way, I think it would be a good idea to contact the RDFQuery
developers to know whether they are interested in adding support for
json-ld to this lib.

--
Olivier
http://twitter.com/ogrisel - http://github.com/ogrisel

Mark Birbeck

unread,
Oct 25, 2010, 10:02:36 AM10/25/10
to jso...@googlegroups.com
Hi Fabian,

I wouldn't say that JSON-LD is an extension of JSON...it's still ordinary JSON.

However, what we're trying to do is provide a way that JSON can be
'interpreted' as RDF. The JSON that can be 'interpreted' will range
from 'plain old JSON' through to JSON that has a bunch of extra clues
in the form of a profile, clearly marked URIs, data types, and so on.

This means that sometimes the JSON that we want to interpret as RDF
will contain nothing that we would recognise as JSON-LD, for example:

{
"name": "Fabian"
}

I think it would be wrong for a document conveying this to have a
different MIME-type. But more than that, it would also be wrong for a
parser to ignore 'plain old JSON' since it may originate from a source
outside of our control, such as a Twitter or Facebook API.

To illustrate, 'plain old JSON' can still be given an RDF
'interpretation', either by adding a JSON-LD context to the object
before processing it:

var obj = {
"name": "Fabian"
};

obj["#"] = { "name": "http://xmlns.com/foaf/0.1/name" };

or by using functions that take a default context as a parameter:

somelibrary.parseJSONLD(
{ "name": "http://xmlns.com/foaf/0.1/name" },
obj
);

This is a made-up function, of course, but it's the kind of thing I
think we'll see in the RDFa API, for example.

So, for all of these reasons, I think JSON-LD is 'just JSON' and the
MIME-type should be set accordingly.

Regards,

Mark

Fabian Christ

unread,
Oct 25, 2010, 10:17:13 AM10/25/10
to jso...@googlegroups.com
Hi Mark,

thank you for this detailed explanation. I understand now the point of
JSON-LD and why there is no need for an json+ld mime-type from the
parser syntax point of view.

But what I still don't understand: How does a parser recognize that
the JSON it receives is JSON-LD? The difference lies not in the syntax
but in the semantic how to interpret special keys, like "#". Should a
JSON-LD parser just try to interpret the received JSON in JSON-LD
manner? What is the criteria to recognize JSON-LD if it is not
provided by the mime-type?

Best regards,
Fabian

2010/10/25 Mark Birbeck <mark.b...@gmail.com>:

--
Fabian

Reply all
Reply to author
Forward
0 new messages