# Code not working in p5.js with JSON data?

**URL:** <https://discourse.processing.org/t/code-not-working-in-p5-js-with-json-data/24152>\
**Category:** Coding Questions\
**Tags:** homework\
**Created:** [September 27, 2020, 2:00pm UTC](https://discourse.processing.org/t/code-not-working-in-p5-js-with-json-data/24152 "2020-09-27T14:00:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sam101](https://avatars.discourse-cdn.com/v4/letter/s/c67d28/32.png) [@sam101](https://discourse.processing.org/u/sam101)\
**Post date:** [September 27, 2020, 2:00pm UTC](https://discourse.processing.org/t/code-not-working-in-p5-js-with-json-data/24152/1 "2020-09-27T14:00:14Z")

</div>

I’m trying to tell the system to let the number value stored within my JSON file to determine the size of the ellipse. I referenced this [https://editor.p5js.org/bavazzanos1/sketches/Bkkdrs11M](https://editor.p5js.org/bavazzanos1/sketches/Bkkdrs11M)

MY CODE SO FAR:

```auto
var data; 
var instagram, snapchat, messenger, facebook, email;
var sizeMultiplier = 20; 
var Size;

function preload (){
  data =loadJSON ("Sunday.json");
}
function setup() {
   createCanvas (windowWidth, windowHeight);
   background (255);
   Size = data.oneam.instagram * sizeMultiplier;
   
   }
   
function draw () { 
background (220); 
fill (20, 40, 50); 
ellipse (width/2, height/2, Number(Size), Number(Size));

```

JSON FILE:

```auto
[
    { 
      "twelveam": {
        "instagram": 0,
        "messenger": 0,
        "snapchat": 0,
        "email": 0,
        "facebook": 0,
        "totalNotification": 0
          }
    },

    {
         "oneam": {
        "instagram": 1,
        "messenger": 2,
        "snapchat": 0,
        "email": 0,
        "facebook": 0,
        "totalNotification": 3
         }
    },
]

```

But I keep getting an error message in console  
 ![Screen Shot 2020-09-27 at 11.58.24 pm](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/3/308361b346a76a22fab8084be9d7f28a13a746c9.png)

Not sure what’s happened here?  
Any feedback would be great!

---

<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 27, 2020, 2:30pm UTC](https://discourse.processing.org/t/code-not-working-in-p5-js-with-json-data/24152/2 "2020-09-27T14:30:04Z")

</div>

> [@sam101](#):
>
> `data.oneam.instagram`

As I had already explained on your previous topic:

> [@How do I draw a circle based on my JSON data information in p5.js?](https://discourse.processing.org/t/how-do-i-draw-a-circle-based-on-my-json-data-information-in-p5-js/24146/2):
>
> [Discourse.Processing.org/faq#format-your-code](http://Discourse.Processing.org/faq#format-your-code) [{ "12:00 am": { "instagram": 0, "messenger": 0, "snapchat": 0, "email": 0, "facebook": 0, "totalNotification": 0 } }, { "1:00 am": { "instagram": 1, "messenger": 2, "snapchat": 0, "email": 0, "facebook": 0, "totalNotification": 3 } }] Given the JSON file is initially wrapped up w/ square brackets [] it means its outer datatype is JSONArray. And you…

Your JSON file is a JSONArray of 2 JSONObject entries.

So you 1st need to specify the indexed entry number in order to access 1 of those JSONObject objects:  
`data[1].oneam.instagram` or `data[1]['oneam']['instagram']`
