# Using Solid with JSON-LD

**URL:** <https://forum.solidproject.org/t/using-solid-with-json-ld/1641>\
**Category:** Become a Pod Provider\
**Created:** [April 7, 2019, 6:35pm UTC](https://forum.solidproject.org/t/using-solid-with-json-ld/1641 "2019-04-07T18:35:16Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![aveltens](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/aveltens/32/3987_2.png) [@aveltens](https://forum.solidproject.org/u/aveltens)\
**Post date:** [April 7, 2019, 6:35pm UTC](https://forum.solidproject.org/t/using-solid-with-json-ld/1641/1 "2019-04-07T18:35:16Z")

</div>

For web developers that are not (yet) accustomed to Linked Data it is much easier to build apps that can handle JSON trees.

Luckily there is [JSON-LD](https://json-ld.org/), a JSON serialization of RDF, and Node Solid Server is able to serialize a resource as such:

```auto
curl --header Accept:application/ld+json https://angelo.veltens.org/profile/card

```

This will give you the data from [my profile](https://angelo.veltens.org/profile/card) as JSON-LD.

Using [JSON-LD Framing](https://w3c.github.io/json-ld-framing/), you can easily apply a context and structure that fits your client app.

```json
{
  "id": "#me",
  "type": [
    "schema:Person",
    "foaf:Person"
  ],
  "photo": "me.jpg",
  "name": "Angelo Veltens"
}

```

This way you can handle Linked Data as if it was just regular JSON. (Because it is, now).

You can find a [running example in the JSON-LD playground](https://json-ld.org/playground/#startTab=tab-framed&json-ld=https%3A%2F%2Fangelo.veltens.org%2Fprofile%2Fcard&frame=%7B%22%40context%22%3A%7B%22id%22%3A%22%40id%22%2C%22type%22%3A%22%40type%22%2C%22%40base%22%3A%22https%3A%2F%2Fangelo.veltens.org%2Fprofile%2Fcard%22%2C%22foaf%22%3A%22http%3A%2F%2Fxmlns.com%2Ffoaf%2F0.1%2F%22%2C%22sioc%22%3A%22http%3A%2F%2Frdfs.org%2Fsioc%2Fns%23%22%2C%22vcard%22%3A%22http%3A%2F%2Fwww.w3.org%2F2006%2Fvcard%2Fns%23%22%2C%22acl%22%3A%22http%3A%2F%2Fwww.w3.org%2Fns%2Fauth%2Facl%23%22%2C%22ldp%22%3A%22http%3A%2F%2Fwww.w3.org%2Fns%2Fldp%23%22%2C%22pim%22%3A%22http%3A%2F%2Fwww.w3.org%2Fns%2Fpim%2Fspace%23%22%2C%22solid%22%3A%22http%3A%2F%2Fwww.w3.org%2Fns%2Fsolid%2Fterms%23%22%2C%22rdfs%22%3A%22http%3A%2F%2Fwww.w3.org%2F2000%2F01%2Frdf-schema%23%22%2C%22sioct%22%3A%22http%3A%2F%2Frdfs.org%2Fsioc%2Ftypes%23%22%2C%22schema%22%3A%22http%3A%2F%2Fschema.org%2F%22%2C%22name%22%3A%22foaf%3Aname%22%2C%22photo%22%3A%7B%22%40id%22%3A%22vcard%3AhasPhoto%22%2C%22%40type%22%3A%22%40id%22%7D%7D%2C%22%40id%22%3A%22%23me%22%2C%22name%22%3A%7B%7D%2C%22photo%22%3A%7B%7D%2C%22%40explicit%22%3Atrue%7D).

Source: [https://angelo.veltens.org/articles/2019/04/solid-with-jsonld](https://angelo.veltens.org/articles/2019/04/solid-with-jsonld)

---

<div class="post-metadata">

**Author:** ![scott](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/scott/32/907_2.png) [@scott](https://forum.solidproject.org/u/scott)\
**Post date:** [April 7, 2019, 7:09pm UTC](https://forum.solidproject.org/t/using-solid-with-json-ld/1641/2 "2019-04-07T19:09:07Z")

</div>

Yup; just had a related conversation, which TBL answered in the Solid Gitter Chat.

I much prefer the JSON-LD syntax and form; makes working with Linked Data much more exciting imo.

Fun stuff!

---

<div class="post-metadata">

**Author:** ![glensimister](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/glensimister/32/1257_2.png) [@glensimister](https://forum.solidproject.org/u/glensimister)\
**Post date:** [May 23, 2019, 12:35pm UTC](https://forum.solidproject.org/t/using-solid-with-json-ld/1641/3 "2019-05-23T12:35:58Z")

</div>

Looks good. How would this work in practice? Are there any examples of apps that use JSON-LD?

---

<div class="post-metadata">

**Author:** ![aveltens](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/aveltens/32/3987_2.png) [@aveltens](https://forum.solidproject.org/u/aveltens)\
**Post date:** [May 23, 2019, 12:39pm UTC](https://forum.solidproject.org/t/using-solid-with-json-ld/1641/4 "2019-05-23T12:39:57Z")

</div>

I am currently working on libraries that are based on JSON-LD. But this ist still in a very early / experimental phase.

> **[Angelo Veltens / hyperprops](https://gitlab.com/angelo-v/hyperprops)**
>
> Connect the web of linked data to your presentational react components.

---

<div class="post-metadata">

**Author:** ![glensimister](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/glensimister/32/1257_2.png) [@glensimister](https://forum.solidproject.org/u/glensimister)\
**Post date:** [May 23, 2019, 12:52pm UTC](https://forum.solidproject.org/t/using-solid-with-json-ld/1641/5 "2019-05-23T12:52:05Z")

</div>

OK thanks. I’m not familiar with react. Could you provide an example using JS? For example, can i do an ajax request and retrieve the results as JSON-LD as opposed to turtle? If so, how?

---

<div class="post-metadata">

**Author:** ![aveltens](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/aveltens/32/3987_2.png) [@aveltens](https://forum.solidproject.org/u/aveltens)\
**Post date:** [May 23, 2019, 12:55pm UTC](https://forum.solidproject.org/t/using-solid-with-json-ld/1641/6 "2019-05-23T12:55:36Z")

</div>

You just have to set the accept header to `Accept:application/ld+json`. You can then use [jsonld.js](https://github.com/digitalbazaar/jsonld.js/) on client side.

---

<div class="post-metadata">

**Author:** ![aveltens](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/aveltens/32/3987_2.png) [@aveltens](https://forum.solidproject.org/u/aveltens)\
**Post date:** [May 23, 2019, 12:58pm UTC](https://forum.solidproject.org/t/using-solid-with-json-ld/1641/7 "2019-05-23T12:58:33Z")

</div>

Here is a JSFiddle that demonstrates applying a client context after loading data from backend

[https://jsfiddle.net/aveltens/d3tzfhjx/](https://jsfiddle.net/aveltens/d3tzfhjx/)
