javascript - Extracting info from a JSON: P5.js -


my php script json_encodes this:

[{"x":"20","y":"24","name":"newnov"},{"x":"20","y":"70","name":"tito"}] 

but can't see how can extract information in p5.js program?

say, need use 'x', 'y', 'name' draw circle in appropriate place right name.

i used loadjson in script, , have variable -

data = loadjson() 

but how get, say, 'x' component 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); } 

thanks comments above, that's worked in end:

 var data;   function preload() {  var url = 'http://localhost/planettrequest.php';  data = loadjson(url);  }   function setup() {  createcanvas(300, 300);  background(153);  noloop();  }   function draw() {  background(200);  textsize(15);  text(data[0].name, 10, 30);  fill(0, 102, 153);  }   

Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -