[21] [DFN[[[JSON-LD]]]] は、 [[W3C]] が提唱する [[Linked Data]]
を [[JSON]] によって記述する[[データ形式]]です。


* 仕様書

[REFS[
- [78] [CITE@en[JSON-LD 1.1]], [TIME[2020-11-14T19:35:19.000Z]], [TIME[2021-01-11T11:14:08.303Z]] <https://w3c.github.io/json-ld-syntax/>
- [79] [CITE@en[JSON-LD 1.1 Processing Algorithms and API]], [TIME[2021-01-07T18:48:54.000Z]], [TIME[2021-01-11T11:14:27.316Z]] <https://w3c.github.io/json-ld-api/>
- [80] [CITE@en[JSON-LD 1.1 Framing]], [TIME[2020-11-14T19:34:11.000Z]], [TIME[2021-01-11T11:14:39.531Z]] <https://w3c.github.io/json-ld-framing/>
]REFS]



* 言語

[73] 一般的な [[JSON]] の[[オブジェクト]]などの構造のうち、
[CODE[@context]] など [CODE[@]]
から始まる名前が [[JSON-LD]] 固有の意味を持つものとなっています。

[82] 
[[JSON-LD]]
のデータモデルは
[[RDFデータモデル]]をベースにしています。

[83] 
[[JSON-LD]] は [[RDFデータモデル]]が使っている [[IRI]]
という古い時代の概念を未だに使い続けています。
現在の [[URL]] に当たりますが、その意味と構文に微妙な違いがいろいろあります。
普通の人には理解困難でしょう。


* 文脈

[71] 単独の[[ファイル]]として用いられる他、
[[スクリプトデータブロック]] (>>27) としても用いられます。

[72] 
[[JSON-LD]] は [[JSON]] の[[応用]]ですから、
[[MIME型]]などの外部的な手段を用いない限り、
ただの [[JSON]] と完全に区別することはできません。
([[オブジェクト]]内の名前などから [[JSON-LD]] っぽいかどうかは判断できます。)

* MIME 型

[32] [[MIME型]] [DFN[[CODE(MIME)@en[application/ld+json]]]] が用いられています。


[76] 
[DFN[[CODE(MIME)@en[[VAR[*]]/[VAR[*]]+ld+json]]]]
が使われることがあります。
e.g.
[CODE(MIME)@en[application/did+ld+json]]



[REFS[
- [62] [CITE[JSON-LD Syntax 1.0]]
( ([TIME[2012-06-27 10:06:49 +09:00]] 版))
<http://json-ld.org/spec/FCGS/json-ld-syntax/20120626/#application-ld-json>
- [63] [CITE@en[JSON-LD 1.0]]
( ([TIME[2014-01-13 20:01:00 +09:00]] 版))
<http://www.w3.org/TR/json-ld/#h3_embedding-json-ld-in-html-documents>
- [64] [CITE@en[JSON-LD 1.0]]
( ([TIME[2014-01-13 20:01:00 +09:00]] 版))
<http://www.w3.org/TR/json-ld/#application-ld-json>

[FIG(quote)[
[FIGCAPTION[
[65] [CITE@en[JSON-LD 1.0]]
([TIME[2015-06-25 15:33:21 +09:00]] 版)
<https://dvcs.w3.org/hg/json-ld/raw-file/default/spec/latest/json-ld/index.html#application-ld-json>
]FIGCAPTION]

>  application/ld+json

]FIG]

[FIG(quote)[
[FIGCAPTION[
[67] [CITE@en[Social Web Protocols]]
( ([TIME[2016-06-03 16:29:47 +09:00]]))
<https://www.w3.org/TR/2016/WD-social-web-protocols-20160603/>
]FIGCAPTION]

> '''['''ActivityStreams2''']''' content must be served with the Content-Type application/activity+json or, if necessary for JSON-LD extended implementations, application/ld+json; profile="http://www.w3.org/ns/activitystreams".

]FIG]


[FIG(quote)[
[FIGCAPTION[
[68] [CITE@en[Web Annotation Data Model]]
([TIME[2017-02-24 02:14:26 +09:00]])
<https://w3c.github.io/web-annotation/model/wd2/#h-serialization-of-the-model>
]FIGCAPTION]

> The media type of this format is defined in Section 3 of the Annotation Protocol '''['''annotation-protocol''']''' as application/ld+json;profile="http://www.w3.org/ns/anno.jsonld".

]FIG]


[FIG(quote)[
[FIGCAPTION[
[69] [CITE@en[Web Annotation Protocol]]
([TIME[2017-02-24 02:14:26 +09:00]])
<https://w3c.github.io/web-annotation/protocol/wd/#h-annotation-retrieval>
]FIGCAPTION]

> Servers must support the JSON-LD representation using the Web Annotation profile. These responses must have a Content-Type header with the application/ld+json media type, and it should have the Web Annotation profile IRI of http://www.w3.org/ns/anno.jsonld in the profile parameter.

]FIG]


[FIG(quote)[
[FIGCAPTION[
[70] [CITE@en[Embedding Web Annotations in HTML]]
([TIME[2017-02-24 02:14:26 +09:00]])
<https://w3c.github.io/web-annotation/serialization-html-note/#embed-json-ld>
]FIGCAPTION]

> JSON-LD '''['''json-ld''']''' is the serialization format used in the Web Annotation Data Model '''['''annotation-model''']'''. HTML can accommodate this serialization format directly via the use of the HTML <script> element with its type attribute assigned the media type for a Web Annotation: application/ld+json;profile="http://www.w3.org/ns/anno.jsonld".

]FIG]

]REFS]

* 応用

[FIG(short list)[ [55] [[JSON-LD]] の[[応用]]
- [[ActivityPub]]
- [[ODRL]]
- [[schema.org]]
- [[Simple Data Format]]

]FIG]

[47] [[Activity Streams 2.0]] は [[JSON-LD]] を使っていますが、
[[JSON-LD]] を使わなくても良いとしています。また、
[[JSON-LD]] と矛盾する拡張がなされる可能性も指摘するなど、
奇怪な使い方をしています。
[SEE[ [[Activity Streams 2.0]] ]]

* スクリプトデータブロック

[27] [[schema.org]] は [[JSON-LD]] により記述して [[HTML]]
に[[スクリプトデータブロック]]として埋め込む方法を定義しており、
[[Google]] などが実装しているようです。

[EG[

[FIG(quote)[
[FIGCAPTION[
[66] ([TIME[2016-04-16 18:03:12 +09:00]] 版)
<http://limia.jp/idea/20387/>
]FIGCAPTION]

> <body>
> <script type="application/ld+json">
> {"@context":"http://schema.org","@type":"BreadcrumbList","itemListElement":'''['''{"@type":"ListItem","position":1,"item":{"@id":"/","name":"LIMIAトップ"}},{"@type":"ListItem","position":2,"item":{"@id":"/idea/","name":"アイデア"}},{"@type":"ListItem","position":3,"item":{"@id":"/ideas/house/","name":"家づくり"}},{"@type":"ListItem","position":4,"item":{"@id":"/idea/20387/","name":"【施工事例】高気密断熱デザイン住宅 r+house 豊中市小曽根 I 様邸"}}''']'''}
> </script>

]FIG]

]EG]

[77] 
ほとんどの場合は[[マイクロデータ]]でも記述できます。
[[マイクロデータ]]は [[HTML]] の本文と一緒に書くのに対して、
[[JSON-LD]] 
は別に [CODE[script]]
[[要素]]を用意して書かなければならないので、
メンテナンスコストの増大につながるのが欠点です。

* 批判

[50] 
[[JSON]] に [[RDF]] 式の[[名前空間]]機構を持ち込んだ [[JSON-LD]] は、
[[XML]] に複雑な [[XML名前空間]]を持ち込ませた [[RDF/XML]]
の轍を踏むものだと非難されています。

[51] 
[[JSON-LD]] が [[Linked Data]]・[[Semantic Web]] [[コミュニティー]]内部で用いられている限りは大した影響はありませんが、
それ以外の一般的な [[Web]] の情報交換に [[JSON-LD]] を組み込もうとする勢力があり、
懐疑的な筋から警戒されているようです。


[56] [[JSON-LD]] は複雑で取扱いが難しいため、 [[Linked Data]] 
以外の場面では使うべきではありません。

[REFS[
- [45] [CITE@ja[Henri Sivonenさんのツイート: "Namespaces were added to XML for RDF. 1/5"]]
([TIME[2017-05-22 23:26:49 +09:00]])
<https://twitter.com/hsivonen/status/866247749477564416>
- [48] [CITE[Namespaces in JSON?]]
([[Norman Walsh]]著, [TIME[2017-05-29 17:41:33 +09:00]])
<https://so.nwalsh.com/2017/05/24/jsns>
- [49] [CITE@en[No Namespaces in JSON, Please]]
([[Henri Sivonen]]著, [TIME[2017-05-26 03:33:17 +09:00]])
<https://hsivonen.fi/no-json-ns/>
]REFS]

* Semantic Web との関係

[26] 一昔前なら [[RDF]]/[[JSON]] とでも呼ばれていたのでしょうが、
[[Semantic Web]] が不発に終わり [[Linked Data]] が新たなキーワードとなり、
[[RDF]] との関係を表に出さない形とされたようです (>>22 参照)。


* 関連

[31] [[LDJSON]] とは無関係です。

* 歴史

[1] [CITE@en[JSON-LD - Linked Data Expression in JSON]]
([TIME[2010-05-31 06:05:06 +09:00]] 版)
<http://rdfa.digitalbazaar.com/specs/source/json-ld/>

[2] [CITE[JSON-LD Syntax 1.0]]
( ([TIME[2012-06-27 10:06:49 +09:00]] 版))
<http://json-ld.org/spec/FCGS/json-ld-syntax/20120626/>

[3] [CITE[JSON-LD API 1.0]]
( ([TIME[2012-06-27 10:09:09 +09:00]] 版))
<http://json-ld.org/spec/FCGS/json-ld-api/20120626/>

[4] [CITE[JSON-LD API 1.0]]
( ([TIME[2012-07-13 03:28:03 +09:00]] 版))
<http://www.w3.org/TR/2012/WD-json-ld-api-20120712/>

[5] [CITE[JSON-LD Syntax 1.0]]
( ([TIME[2012-07-13 03:19:33 +09:00]] 版))
<http://www.w3.org/TR/2012/WD-json-ld-syntax-20120712/>

[6] [CITE[''''''[''''''whatwg'''''']'''''' Was is considered to use JSON-LD instead of creating application/microdata+json?]]
( ([TIME[2012-08-11 02:12:02 +09:00]] 版))
<http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2012-August/036871.html>

[7] [CITE[JSON-LD 1.0]]
( ([TIME[2013-04-11 01:38:23 +09:00]] 版))
<http://www.w3.org/TR/2013/WD-json-ld-20130411/>

[8] [CITE[JSON-LD 1.0 Processing Algorithms and API]]
( ([TIME[2013-04-11 01:39:33 +09:00]] 版))
<http://www.w3.org/TR/2013/WD-json-ld-api-20130411/>

[9] [CITE@en[JSON-LD 1.0]]
( ([TIME[2013-09-10 00:34:33 +09:00]] 版))
<http://www.w3.org/TR/2013/CR-json-ld-20130910/>

[10] [CITE@en[JSON-LD 1.0 Processing Algorithms and API]]
( ([TIME[2013-09-10 00:34:34 +09:00]] 版))
<http://www.w3.org/TR/2013/CR-json-ld-api-20130910/>

[11] [CITE@en[JSON-LD 1.0]]
( ([TIME[2013-11-02 00:30:19 +09:00]] 版))
<http://www.w3.org/TR/2013/PR-json-ld-20131105/>

[12] [CITE@en[JSON-LD 1.0 Processing Algorithms and API]]
( ([TIME[2013-11-02 00:30:19 +09:00]] 版))
<http://www.w3.org/TR/2013/PR-json-ld-api-20131105/>

[13] [CITE@en[Go-To Actions - Actions in the Inbox — Google Developers]]
( ([TIME[2013-10-18 18:01:07 +09:00]] 版))
<https://developers.google.com/gmail/actions/reference/go-to-action?hl=ja>

[14] [CITE@en[JSON-LD in examples invalid due to comments]]
( ([[Markus Lanthaler]] 著, [TIME[2013-11-28 19:45:52 +09:00]] 版))
<http://lists.w3.org/Archives/Public/public-vocabs/2013Nov/0215.html>

[15] [CITE@en[JSON-LD 1.0]]
( ([TIME[2014-01-13 20:01:00 +09:00]] 版))
<http://www.w3.org/TR/2014/REC-json-ld-20140116/>

[16] [CITE@en[JSON-LD 1.0]]
( ([TIME[2014-01-13 20:01:00 +09:00]] 版))
<http://www.w3.org/TR/json-ld/>

[17] [CITE@en[JSON-LD 1.0 Implementation Report]]
( ([TIME[2014-01-19 18:26:43 +09:00]] 版))
<https://dvcs.w3.org/hg/json-ld/raw-file/default/test-suite/reports/cr-20131022.html>

[18] [CITE[JSON LD Errata - Semantic Web Standards]]
( ([TIME[2014-01-17 02:57:09 +09:00]] 版))
<http://www.w3.org/2001/sw/wiki/JSON_LD_Errata>

[19] [CITE@en[JSON-LD 1.0 Processing Algorithms and API]]
( ([TIME[2014-01-13 20:02:37 +09:00]] 版))
<http://www.w3.org/TR/2014/REC-json-ld-api-20140116/>

[20] [CITE@en[JSON-LD 1.0 Processing Algorithms and API]]
( ([TIME[2014-01-13 20:02:37 +09:00]] 版))
<http://www.w3.org/TR/json-ld-api/>

[22] [CITE@en[JSON-LD - JSON for Linking Data]]
([TIME[2015-04-04 13:59:21 +09:00]] 版)
<http://json-ld.org/>

[FIG(quote)[
[FIGCAPTION[
[23] [CITE@en-US[JSON-LD and Why I Hate the Semantic Web | The Beautiful, Tormented Machine]]
([TIME[2015-04-05 22:04:03 +09:00]] 版)
<http://manu.sporny.org/2014/json-ld-origins-2/>
]FIGCAPTION]

> Many W3C specifications are so cryptic that they require the sacrifice of your sanity and a secret W3C decoder ring to read. I never understood why these documents were so difficult to read, and after years of study on the matter, I think I found the answer. It turns out that most specification editors are just crap at writing.

]FIG]


-[24] [CITE@en-US[The Origins of JSON-LD | The Beautiful, Tormented Machine]]
([TIME[2015-04-05 22:04:30 +09:00]] 版)
<http://manu.sporny.org/2014/json-ld-origins/>
-- [84] 消滅確認 [TIME[2023-06-13T11:57:59.800Z]]
-- [85] [CITE@en-US[The Origins of JSON-LD | The Beautiful, Tormented Machine]], [TIME[2023-06-13T11:57:46.000Z]], [TIME[2014-01-21T08:27:15.666Z]] <https://web.archive.org/web/20140121082710/http://manu.sporny.org/2014/json-ld-origins/>

[25] [CITE@en[Official Google Webmaster Central Blog: Easier website development with Web Components and JSON-LD]]
([TIME[2015-04-01 01:09:39 +09:00]] 版)
<http://googlewebmastercentral.blogspot.jp/2015/03/easier-website-development-with-web.html>






[FIG(quote)[
[FIGCAPTION[
[33] [CITE@en-US[The Web Browser API Incubation Anti-Pattern | The Beautiful, Tormented Machine]]
([TIME[2016-04-16 01:45:20 +09:00]] 版)
<http://manu.sporny.org/2016/browser-api-incubation-antipattern/>
]FIGCAPTION]

> the editors of the Web Payments Community Group specifications discovered (through a backchannel discussion) that “the browser vendors are never going to adopt JSON-LD and the Web Payments Community Group specification will never gain traction as a result”. The Web Payments Community Group specifications used JSON-LD to meet the extensibility needs of Web Payments. This desire to not use JSON-LD by the browser vendors was never communicated through any public channel nor was it directly communicated by the browser vendors privately.

]FIG]


[34] [CITE@en[JSON-LD API Best Practices note]]
( ([[Gregg Kellogg]]著, [TIME[2016-06-07 03:29:49 +09:00]]))
<https://lists.w3.org/Archives/Public/public-linked-json/2016Jun/0002.html>

[35] [CITE@en[Building JSON-LD APIs: Best Practices]]
( ([TIME[2016-06-08 09:13:18 +09:00]]))
<http://json-ld.org/spec/latest/json-ld-api-best-practices/>

[FIG(quote)[
[FIGCAPTION[
[36] [CITE@en['''['''Fwd: '''['''wbs''']''' response to 'Call for Review: Web of Things Working  Group Charter'''']''']]
([[L. David Baron]]著, [TIME[2016-10-15 09:54:22 +09:00]])
<https://lists.w3.org/Archives/Public/www-archive/2016Oct/0004.html>
]FIGCAPTION]

> We are also concerned about the clauses in the charter tying the group
> to RDF, JSON-LD, and other technologies that have not been widely
> accepted by Web developers, and which could burden the group with
> considerable unneeded complexity.

]FIG]


[FIG(quote)[
[FIGCAPTION[
[37] [CITE[Raptor RDF Syntax Library]]
([TIME[2014-12-16 11:41:45 +09:00]])
<http://librdf.org/raptor/>
]FIGCAPTION]

> JSON-LD is not supported - too complex to implement.

]FIG]


[FIG(quote)[
[FIGCAPTION[
[38] [CITE[PubChemRDF Release Notes]]
([TIME[2016-09-14 23:56:18 +09:00]])
<https://pubchem.ncbi.nlm.nih.gov/rdf/#_Toc421254649>
]FIGCAPTION]

> JSON-LDc 
> application/x-json+ld
> application/x-json+rdf
> application/json+ld
> application/json+rdf
> application/ld+json
> application/rdf+json
> Jsonld
> Json-ld
> ldjson
> ld-json

]FIG]


[39] [CITE[Project Open Data Metadata Schema v1.1 - Project Open Data]]
([TIME[2016-10-27 04:39:17 +09:00]])
<https://project-open-data.cio.gov/v1.1/schema/>

[FIG(quote)[
[FIGCAPTION[
[40] [CITE@en[remoteStorage ‒ An open protocol for per-user storage on the Web]]
([TIME[2016-07-18 04:17:28 +09:00]])
<https://remotestorage.io/>
]FIGCAPTION]

> In addition to that – and the only special feature aside from plain HTTP – there are directory listings, formatted as JSON-LD. They contain both the content type and size, as well as ETags, which can be used to implement sync mechanisms. The files and listings themselves also carry ETag headers for sync/caching and conditional requests.

]FIG]


[FIG(quote)[
[FIGCAPTION[
[41] [CITE@en[remoteStorage ‒ An open protocol for per-user storage on the Web]]
([TIME[2016-07-18 04:17:28 +09:00]])
<https://remotestorage.io/>
]FIGCAPTION]

> In addition to that – and the only special feature aside from plain HTTP – there are directory listings, formatted as JSON-LD. They contain both the content type and size, as well as ETags, which can be used to implement sync mechanisms. The files and listings themselves also carry ETag headers for sync/caching and conditional requests.

]FIG]


[42] [CITE@en[Scoped Contexts]]
([[Gregg Kellogg]]著, [TIME[2017-01-02 11:23:59 +09:00]])
<https://lists.w3.org/Archives/Public/public-linked-json/2017Jan/0000.html>

[43] [CITE@en[Web Annotation Vocabulary]]
([TIME[2017-02-24 02:14:26 +09:00]])
<https://w3c.github.io/web-annotation/vocab/wd/#h-extensions>

[FIG(quote)[
[FIGCAPTION[
[44] [CITE@en[Web Annotation Vocabulary]]
([TIME[2017-02-24 02:14:26 +09:00]])
<https://w3c.github.io/web-annotation/vocab/wd/#h-extensions>
]FIGCAPTION]

> Note that the current JSON-LD '''['''JSON-LD''']''' specification does not allow arrays to contain other arrays directly. As JSON-LD is the recommended serialization format, extensions should avoid the use of this pattern.

]FIG]



[FIG(quote)[
[FIGCAPTION[
[46] [CITE@en[Activity Streams 2.0]]
([TIME[2017-05-21 23:50:36 +09:00]])
<https://w3c.github.io/activitystreams/core/#h-media-type>
]FIGCAPTION]

> Because Activity Streams 2.0 can be considered a restricted profile of JSON-LD, Implementations should consider the `application/ld+json; profile="https://www.w3.org/ns/activitystreams"` media type as being equivalent to `application/activity+json`.

]FIG]



[52] [CITE@en[Application data schemas & how to manage decentralized development · Issue #820 · beakerbrowser/beaker]]
([TIME[2018-02-05 23:01:40 +09:00]])
<https://github.com/beakerbrowser/beaker/issues/820>

[53] [CITE@en[JSON-LD 1.1 Working Group vote]]
([[Robert Sanderson]]著, [TIME[2018-03-16 03:03:38 +09:00]])
<https://lists.w3.org/Archives/Public/public-linked-json/2018Mar/0009.html>

[54] [CITE@en[json-ld/json-ld.org: JSON for Linked Data]]
([TIME[2018-03-19 23:32:40 +09:00]])
<https://github.com/json-ld/json-ld.org>

[57] [CITE@en[Google's response to 'Call for Review: JSON-LD Working Group Charter'  (fwd)]]
([[Coralie Mercier]]著, [TIME[2018-05-02 03:44:59 +09:00]])
<https://lists.w3.org/Archives/Public/public-new-work/2018May/0000.html>

[58] [CITE@en['''['''wbs''']''' response to 'Call for Review: JSON-LD Working Group Charter']]
([[David Baron via WBS Mailer]]著, [TIME[2018-04-30 02:27:03 +09:00]])
<https://lists.w3.org/Archives/Public/public-new-work/2018Apr/0012.html>

[59] [CITE@en[W3C JSON-LD Working Group]]
([TIME[2018-06-12 04:25:12 +09:00]])
<https://www.w3.org/2018/json-ld-wg/>

[60] [CITE@en[Request for Position: Web Thing API · Issue #44 · mozilla/standards-positions]]
([TIME[2018-08-03 01:35:21 +09:00]])
<https://github.com/mozilla/standards-positions/issues/44>

[61] [CITE@en[W3C JSON-LD Working Group]]
([TIME[2018-09-15 03:49:43 +09:00]])
<https://www.w3.org/2018/json-ld-wg/WorkMode/guiding_principles>

[74] [CITE@en-US[JSON-LD Collaborative Work and Feature Timeline | W3C Blog]]
([TIME[2019-03-19 14:31:49 +09:00]])
<https://www.w3.org/blog/2019/03/json-ld-collaborative-work-and-feature-timeline/>

[75] [CITE@en-US[JSON-LD Working Group Charter]]
([TIME[2018-06-07 16:15:26 +09:00]])
<https://www.w3.org/2018/03/jsonld-wg-charter.html>




[REFS[
- [28] [CITE@en[JSON-LD 1.0]] ([TIME[2015-06-25 15:22:11 +09:00]] 版) <https://dvcs.w3.org/hg/json-ld/raw-file/default/spec/latest/json-ld/index.html>
- [29] [CITE@en[JSON-LD 1.0 Processing Algorithms and API]] ([TIME[2015-06-25 15:24:07 +09:00]] 版) <https://dvcs.w3.org/hg/json-ld/raw-file/default/spec/latest/json-ld-api/index.html>
- [30] [CITE@en[JSON-LD Framing 1.0]] ([TIME[2013-03-28 23:16:48 +09:00]] 版) <http://json-ld.org/spec/latest/json-ld-framing/>
]REFS]



[81] 
簡単だみたいに謳ってるけどすごい巨大で複雑な仕様だなあ。。。
