# IPLD and how to create links

**URL:** <https://discuss.ipfs.tech/t/ipld-and-how-to-create-links/10037>\
**Category:** Help\
**Created:** [January 29, 2021, 2:49pm UTC](https://discuss.ipfs.tech/t/ipld-and-how-to-create-links/10037 "2021-01-29T14:49:50Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![zacharywhitley](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/zacharywhitley/32/2670_2.png) [@zacharywhitley](https://discuss.ipfs.tech/u/zacharywhitley)\
**Post date:** [January 29, 2021, 2:49pm UTC](https://discuss.ipfs.tech/t/ipld-and-how-to-create-links/10037/1 "2021-01-29T14:49:50Z")

</div>

I have a couple of general questions about IPLD so I’ll just gather them here instead of making a ton of separate posts.

Can IPLD link to IPNS records? If yes it seems like there should be a way to limit `ipfs dag export` since you can’t know beforehand how far out it will go.

What formats does the `ipfs dag put` command take? The help output doesn’t say.

I’m a little confused about json and cbor. I thought that if you gave the command a json file it would be added as cbor but I see there is a dag-cbor but I’ve also seen references to deg-json. I’m wondering how dag-json would even work since, as far as I know, there isn’t a canonical json serialization that would lead to a byte identical serialization.

How does ipfs identify links in a document that you pass to `ipfs dag put`? Does it just look for values that look like CID’s. I’ve also seen a reference to them looking like objects like `{“/”: “Qmfwqer93j23ijrweorjwko”}. I can’t seem to find much documentation on this subject.

---

<div class="post-metadata">

**Author:** ![hector](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/hector/32/178_2.png) [@hector](https://discuss.ipfs.tech/u/hector)\
**Post date:** [January 29, 2021, 3:36pm UTC](https://discuss.ipfs.tech/t/ipld-and-how-to-create-links/10037/2 "2021-01-29T15:36:41Z")

</div>

> [@zacharywhitley](#):
>
> Can IPLD link to IPNS records? If yes it seems like there should be a way to limit `ipfs dag export` since you can’t know beforehand how far out it will go.

No, at least I don’t think so (assuming you mean an IPLD object linking an IPNS hash that needs to be resolved). But re `ipfs dag export`, you cannot know how far it will go, you have to walk a DAG and the bottom is unknown.

> [@zacharywhitley](#):
>
> What formats does the `ipfs dag put` command take? The help output doesn’t say.

The `--format` would be one of these: [https://github.com/ipfs/go-ipfs/blob/7588a6a52a789fa951e1c4916cee5c7a304912c2/core/coredag/dagtransl.go#L20](https://github.com/ipfs/go-ipfs/blob/7588a6a52a789fa951e1c4916cee5c7a304912c2/core/coredag/dagtransl.go#L20)

> [@zacharywhitley](#):
>
> I’m a little confused about json and cbor. I thought that if you gave the command a json file it would be added as cbor

The default `--input-enc` and `--format` flags are json and cbor. So yes. But you can also give it a binary protobuf and it will convert cbor just like it does between json and cbor (hopefully, I haven’t tried).

The very simplified idea is that IPLD nodes are just json-like objects and you can serialize them in arbitrary formats, be it json or cbor or protobuf. i.e. `ipfs dag get` spews out a json when you get a merkledag-protobuf node.

> [@zacharywhitley](#):
>
> How does ipfs identify links in a document that you pass to `ipfs dag put` ? Does it just look for values that look like CID’s. I’ve also seen a reference to them looking like objects like `{"/": “Qmfwqer93j23ijrweorjwko”}`. I can’t seem to find much documentation on this subject.

Yes, `<cid>.toJSON()` produces `{"/": "<cid>"}`, so that type of JSON-objects are parsed as IPLD “links” when deserializing JSON.

---

<div class="post-metadata">

**Author:** ![zacharywhitley](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/zacharywhitley/32/2670_2.png) [@zacharywhitley](https://discuss.ipfs.tech/u/zacharywhitley)\
**Post date:** [January 29, 2021, 3:42pm UTC](https://discuss.ipfs.tech/t/ipld-and-how-to-create-links/10037/3 "2021-01-29T15:42:38Z")

</div>

Thanks @hector. I’m really enjoying getting to know the nooks-and-crannies of IPFS and this is a big help.

One quick followup. The link serialization `"/": "<cid>"}` what is the interpretation of the key? Is it always a single slash or can it be something more complex?

---

<div class="post-metadata">

**Author:** ![hector](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/hector/32/178_2.png) [@hector](https://discuss.ipfs.tech/u/hector)\
**Post date:** [January 29, 2021, 3:46pm UTC](https://discuss.ipfs.tech/t/ipld-and-how-to-create-links/10037/4 "2021-01-29T15:46:52Z")

</div>

It is always a `"/"`. Always. It must be.

Why? I don’t know. Do I hate that it is a slash? Yes.

---

<div class="post-metadata">

**Author:** ![zacharywhitley](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/zacharywhitley/32/2670_2.png) [@zacharywhitley](https://discuss.ipfs.tech/u/zacharywhitley)\
**Post date:** [January 29, 2021, 3:49pm UTC](https://discuss.ipfs.tech/t/ipld-and-how-to-create-links/10037/5 "2021-01-29T15:49:05Z")

</div>

Seems like a pain when you’ve got something else in there that also has a slash for a key but isn’t a link. You’d think something like “ipfs-cid-link” would be less dangerous and more informative. Oh well. Good to know. Thanks

---

<div class="post-metadata">

**Author:** ![hector](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/hector/32/178_2.png) [@hector](https://discuss.ipfs.tech/u/hector)\
**Post date:** [January 29, 2021, 4:00pm UTC](https://discuss.ipfs.tech/t/ipld-and-how-to-create-links/10037/6 "2021-01-29T16:00:00Z")

</div>

For me the problem is that piping an json-dag to `jq` and trying to navigate to the actual cid is a horrible pain of scaping left and right.

Also, it needs to be the full object, with a single `/` key. You cannot add more keys to that object if you want it parsed as CID (I think).
