# How can I read this json file?

**URL:** <https://discourse.processing.org/t/how-can-i-read-this-json-file/21623>\
**Category:** Coding Questions\
**Created:** [June 6, 2020, 2:12pm UTC](https://discourse.processing.org/t/how-can-i-read-this-json-file/21623 "2020-06-06T14:12:29Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sasaKDH](https://avatars.discourse-cdn.com/v4/letter/s/779978/32.png) [@sasaKDH](https://discourse.processing.org/u/sasaKDH)\
**Post date:** [June 6, 2020, 2:12pm UTC](https://discourse.processing.org/t/how-can-i-read-this-json-file/21623/1 "2020-06-06T14:12:29Z")

</div>

sppo works right but, spid doesn’t  
I think they have same structure so, I can’t understand.  
Here is the structure of spid

 ![제이슨](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/7/754b3308775c61ef0d1aa5ddf66577a62bce2a76.png)

```auto
function setup() {
  createCanvas(300, 300);
  sppo = loadJSON("../jsons/spposition.json");
  spid = loadJSON("https://static.api.nexon.co.kr/fifaonline4/latest/spid.json");
}

function draw() {
  background(255);
  fill(0);
  text(sppo[0]["desc"],20,20);
  text(spid[3]["name"],20,60);
}

```

---

<div class="post-metadata">

**Author:** ![crafah](https://avatars.discourse-cdn.com/v4/letter/c/ebca7d/32.png) [@crafah](https://discourse.processing.org/u/crafah)\
**Post date:** [June 6, 2020, 2:22pm UTC](https://discourse.processing.org/t/how-can-i-read-this-json-file/21623/2 "2020-06-06T14:22:25Z")

</div>

Are you seeing any errors in the console in your browser?

---

<div class="post-metadata">

**Author:** ![Sven](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sven/32/8293_2.png) [@Sven](https://discourse.processing.org/u/Sven)\
**Post date:** [June 6, 2020, 2:33pm UTC](https://discourse.processing.org/t/how-can-i-read-this-json-file/21623/3 "2020-06-06T14:33:34Z")

</div>

`loadJSON` is asynchronous, meaning it may not have finished when `draw` is called. The [documentation for `loadJSON`](https://p5js.org/reference/#/p5/loadJSON) shows how to handle that using a callback function or by fetching the JSON file inside the `preload` function.

---

<div class="post-metadata">

**Author:** ![sasaKDH](https://avatars.discourse-cdn.com/v4/letter/s/779978/32.png) [@sasaKDH](https://discourse.processing.org/u/sasaKDH)\
**Post date:** [June 6, 2020, 3:02pm UTC](https://discourse.processing.org/t/how-can-i-read-this-json-file/21623/4 "2020-06-06T15:02:18Z")

</div>

I didn’t think about checking the console because it was my first time programming.  
There are many messages.

 ![오류](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/f/f2d9714d9806ee53ce31f074323e1de7336b288e.png)

- on atom-live-server sppo works and spid doesn’t. But, on github io both don’t work.

---

<div class="post-metadata">

**Author:** ![sasaKDH](https://avatars.discourse-cdn.com/v4/letter/s/779978/32.png) [@sasaKDH](https://discourse.processing.org/u/sasaKDH)\
**Post date:** [June 6, 2020, 3:03pm UTC](https://discourse.processing.org/t/how-can-i-read-this-json-file/21623/5 "2020-06-06T15:03:42Z")

</div>

Thanks, now I use preload function but it still doesn’t work ☹

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [June 6, 2020, 5:11pm UTC](https://discourse.processing.org/t/how-can-i-read-this-json-file/21623/6 "2020-06-06T17:11:50Z")

</div>

> **[loadXML() from EkstraBladet via Proxy](https://bl.ocks.org/GoSubRoutine/5bdec67b4f70080bfddb6c0607cb6c70)**
>
> GoSubRoutine’s Block 5bdec67b4f70080bfddb6c0607cb6c70
