xxxxxxxxxx
var jsonData;
function setup() {
createCanvas(windowWidth, windowHeight);
background(100);
loadStrings("https://www.alphavantage.co/query?function=SMA&symbol=aapl&interval=1min&time_period=10&series_type=close&apikey=82FTVBGL3OKUNTS7",dataLoaded);
}
function dataLoaded(data)
{
println('loaded');
jsonData = data.join().replace(/{,/g,"{"); //remove all {, string
jsonData = jsonData.replace(/,,/g,","); // remove all ,, string
jsonData = jsonData.replace(/[\n\r\s]+/g,''); //remove all carriage return and spaces
jsonData = jsonData.replace(/,}/g,"}"); //remove all ,} string
jsonData = JSON.parse(jsonData);
var counter = 0;
for (var prop in jsonData["TechnicalAnalysis:SMA"]) {
if (counter < 10) {
print(jsonData["TechnicalAnalysis:SMA"][prop]["SMA"]);
}
counter++;
}
print(jsonData["TechnicalAnalysis:SMA"]["2017-11-2413:00"]["SMA"]);
}
function draw() {
ellipse(mouseX, mouseY, 20, 20);
}