my php script json_encodes this:
[{"x":"20","y":"24","name":"NewNov"},{"x":"20","y":"70","name":"Tito"}]
But I can't see how I can extract this information in my p5.js program?
Say, I need to use those 'x', 'y', 'name' to draw a circle in the appropriate place with the right name.
I used loadJSON in the script, and now I have a variable -
data = loadJSON()
But how do I get, say, the 'x' component from the JSON?
var radius;
function preload() {
var url = 'http://localhost/planetTrequest.php';
radius = loadJSON(url);
}
function setup() {
createCanvas(300, 300);
background(153);
noLoop();
}
function draw() {
background(200);
textSize(15);
text(radius.x, 10, 30);
fill(0, 102, 153);
}