# Fork, replace json source with similar external source

**URL:** <https://talk.observablehq.com/t/fork-replace-json-source-with-similar-external-source/7942>\
**Category:** Help\
**Created:** [May 17, 2023, 9:12am UTC](https://talk.observablehq.com/t/fork-replace-json-source-with-similar-external-source/7942 "2023-05-17T09:12:31Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gerritjan](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/gerritjan/32/7737_2.png) [@Gerritjan](https://talk.observablehq.com/u/Gerritjan)\
**Post date:** [May 17, 2023, 9:12am UTC](https://talk.observablehq.com/t/fork-replace-json-source-with-similar-external-source/7942/1 "2023-05-17T09:12:31Z")

</div>

Hi  
I’m new to observable and I’m trying the great ‘examples’.  
I already had great feedback from my ‘viewers’ by forking a interesting example like ’ Zoomable Sunburst’  
All I had to do is replace the line:  
data = FileAttachment(“xxx.json”).json() with my uploaded json

What would you suggest if I would like to ‘get’ the json directly from our datasource  
(is it possible at all?)  
[https://www.waihonapedia.org/xwiki/bin/view/waihonaBase/WLL0.json?xpage=plain](https://www.waihonapedia.org/xwiki/bin/view/waihonaBase/WLL0.json?xpage=plain)

I think the json on that page is valid?

---

<div class="post-metadata">

**Author:** ![mootari](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mootari/32/581_2.png) [@mootari](https://talk.observablehq.com/u/mootari)\
**Post date:** [May 17, 2023, 9:49am UTC](https://talk.observablehq.com/t/fork-replace-json-source-with-similar-external-source/7942/2 "2023-05-17T09:49:44Z")

</div>

> [@Gerritjan](#):
>
> I think the json on that page is valid?

Not in the sense that it’s a parseable JSON document. What you see there is JSON as _text_ inside an HTML document. I assume that in order to be retrievable the JSON needs to be added as a media upload, not as a wiki page.

Additionally it seems that the page serves no [CORS headers](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS), preventing your notebook from fetching it dynamically.

It might become more clear if you access the page through the [/bin/get route](https://www.xwiki.org/xwiki/bin/view/Documentation/DevGuide/Architecture/URL%20Architecture/Standard%20URL%20Format/#HType:bin): [https://www.waihonapedia.org/xwiki/bin/get/waihonaBase/WLL0.json](https://www.waihonapedia.org/xwiki/bin/get/waihonaBase/WLL0.json)

---

<div class="post-metadata">

**Author:** ![Gerritjan](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/gerritjan/32/7737_2.png) [@Gerritjan](https://talk.observablehq.com/u/Gerritjan)\
**Post date:** [May 17, 2023, 10:43am UTC](https://talk.observablehq.com/t/fork-replace-json-source-with-similar-external-source/7942/3 "2023-05-17T10:43:06Z")

</div>

Hi,

Yes, but when the ?xpage=plain is used it should not have the HTML around it?  
Maybe these query params can not easily be used to ‘get’ json?

But this can be easily transformed by our data sourcing team…

---

<div class="post-metadata">

**Author:** ![mootari](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mootari/32/581_2.png) [@mootari](https://talk.observablehq.com/u/mootari)\
**Post date:** [May 17, 2023, 12:01pm UTC](https://talk.observablehq.com/t/fork-replace-json-source-with-similar-external-source/7942/4 "2023-05-17T12:01:50Z")

</div>

> [@Gerritjan](#):
>
> Yes, but when the ?xpage=plain is used it should not have the HTML around it?

No, `?xpage=plain` only removes the XWiki UI, but still serves an HTML page: [Standard URL Format (XWiki.org)](https://www.xwiki.org/xwiki/bin/view/Documentation/DevGuide/Architecture/URL%20Architecture/Standard%20URL%20Format/#HParameter:xpage)

The text is wrapped in a single `<p>` with a `<br>` before and after it.

---

<div class="post-metadata">

**Author:** ![Gerritjan](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/gerritjan/32/7737_2.png) [@Gerritjan](https://talk.observablehq.com/u/Gerritjan)\
**Post date:** [May 18, 2023, 11:31am UTC](https://talk.observablehq.com/t/fork-replace-json-source-with-similar-external-source/7942/5 "2023-05-18T11:31:42Z")

</div>

You seem to know the xwiki platform that indeed is our datasource platform?

While I can code velocity on the platform to construct the json, I’m not an expert on how to structure the url. If you do not know I can ask the xwiki team for advice…

---

<div class="post-metadata">

**Author:** ![mootari](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mootari/32/581_2.png) [@mootari](https://talk.observablehq.com/u/mootari)\
**Post date:** [May 18, 2023, 12:10pm UTC](https://talk.observablehq.com/t/fork-replace-json-source-with-similar-external-source/7942/6 "2023-05-18T12:10:02Z")

</div>

> [@Gerritjan](#):
>
> You seem to know the xwiki platform that indeed is our datasource platform?

No, I only know what I gleaned from the URL and a brief Google search. 🙂

xwiki related questions are certainly out of scope for this forum though.

---

<div class="post-metadata">

**Author:** ![Gerritjan](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/gerritjan/32/7737_2.png) [@Gerritjan](https://talk.observablehq.com/u/Gerritjan)\
**Post date:** [May 18, 2023, 12:38pm UTC](https://talk.observablehq.com/t/fork-replace-json-source-with-similar-external-source/7942/7 "2023-05-18T12:38:57Z")

</div>

Yep, understood.

Assume we get a correct json directly from the source

How should I replace the line:  
data = FileAttachment(“xxx.json”).json()  
in the forked observable script?

Often I encounter that a javascript will run regardless of if the data is available (due to potential delay with internet sources)

---

<div class="post-metadata">

**Author:** ![mootari](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mootari/32/581_2.png) [@mootari](https://talk.observablehq.com/u/mootari)\
**Post date:** [May 18, 2023, 2:05pm UTC](https://talk.observablehq.com/t/fork-replace-json-source-with-similar-external-source/7942/8 "2023-05-18T14:05:33Z")

</div>

You can retrieve your data with fetch:

```auto
data = fetch("https://example.com/the-data.json").then(response => response.json())

```
