So, I’m trying to grab data from my JSON file to my code and display the circle size according to the number on my JSON file.
So far this is the code.
var data;
var instagram, snapchat, messenger, facebook, email, instagramCol, snapchatCol, messengerCol, facebookCol, emailCol;
var sizeMultiplier = 20;
var time, size;
function preload (){
data =loadJSON (“Sunday.json”);
}
function setup() {
createCanvas (windowWidth, windowHeight);
background (255);
instagramCol = color (142, 68, 173);
messengerCol = color (133, 193, 233);
snapchatCol = color (247, 220, 111);
facebookCol = color (118, 215, 196);
emailCol = color (178, 186, 187);
}
function draw () {
//12:00 am data
fill (instagramCol);
size = data.[1].[1]*sizeMultiplier; // looking at the 2th array and the first app which would be Messenger. the number is 2, so therefore it would be 2 X 20 right?
circle (500, 500, size);
}
so this comes up with an error saying "Expected an identifier and instead saw ‘[’
I also tried the code this way as well. size = data[1][1]*sizeMultiplier;
This way works, but nothing shows on screen…I also check the console and no errors have popped up.
This is the JSON 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
}
},
]