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
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, preventing your notebook from fetching it dynamically.
It might become more clear if you access the page through the /bin/get route: https://www.waihonapedia.org/xwiki/bin/get/waihonaBase/WLL0.json
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…
No, ?xpage=plain
only removes the XWiki UI, but still serves an HTML page: 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.
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…
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.
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)
You can retrieve your data with fetch:
data = fetch("https://example.com/the-data.json").then(response => response.json())