# Trouble with code linking to JSON file in p5.js?

**URL:** <https://discourse.processing.org/t/trouble-with-code-linking-to-json-file-in-p5-js/24241>\
**Category:** Coding Questions\
**Tags:** homework\
**Created:** [September 30, 2020, 1:42pm UTC](https://discourse.processing.org/t/trouble-with-code-linking-to-json-file-in-p5-js/24241 "2020-09-30T13:42:05Z")\
**Posts on this page:** 1\
**Showing post:** 3

<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:** [September 30, 2020, 4:38pm UTC](https://discourse.processing.org/t/trouble-with-code-linking-to-json-file-in-p5-js/24241/3 "2020-09-30T16:38:07Z")

</div>

> [@sam101](#):
>
> `data.Sunday[SundayHours].hours[whichHour].instagram*sizeMultiplier`

- The property _Sunday_ points to a JSONObject containing 1 property named _hours_.
- Therefore you can’t use numerical-index access for it!
- Now the internal property _hours_ indeed points to a JSONArray.
- So you’re right using numerical-index access for that property.
- Each element in _hours_ is a JSONObject.
- Seems like you’re particularly interested in accessing the _instagram_ property’s value from each JSONObject element.
- So I’ve made a demo sketch called “JSON Weekdays Access” & hosted it online.
- Although you should run it locally or somewhere else in order to view its entire output.
- That sketch grabs both _time_ & _instagram_ properties and logs them on the page & console grouped by weekdays.

> **[JSON Weekdays Access - GoToLoop - OpenProcessing](https://openprocessing.org/sketch/975186)**

BtW, I’m using the JSON content from my previous answer:

> [@Trouble Writing JSON code?](https://discourse.processing.org/t/trouble-writing-json-code/24232/2):
>
> In order to help me out I’ve used a JSON beautifier service site: lipstick This is what I’ve come up with by duplicating the whole property “Sunday” as “Monday”: bulb { "Sunday": { "hours": [ { "time": "12:00 am", "instagram": 0, "messenger": 0, "snapchat": 0, "email": 0, "facebook": 0, "totalNotification": 0 }, { "time": "1:00 am", "instagram": 1, "messenger": 2, "snapchat": 0…

[OpenProcessing-UserContent.s3.AmazonaWS.com/files/user22279/visual975186/h4bc21ee7a477aaa173e99631b0328e4d/weekdays.json](http://OpenProcessing-UserContent.s3.AmazonaWS.com/files/user22279/visual975186/h4bc21ee7a477aaa173e99631b0328e4d/weekdays.json)

---

_[View the full topic](https://discourse.processing.org/t/trouble-with-code-linking-to-json-file-in-p5-js/24241)._
