Any help with the Javascript needed to grab JSON would be fantastic!!
in
Processing with Other Languages
•
3 months ago
Hi guys,
Totally frustrated with the learning curve. What I want to do is pretty simple.
I want to grab this feed
http://api.thingspeak.com/channels/5384/feed/last.json?status=true
and get the data into this simple test sketch which i will run in processing.js
I have been playing around with formatting the data based on a local CSV file version. I would prefer to grab the CSV from the web server but it seems I can't do that with loadStrings() as it only works for a local file (Or file on the same domain).
It looks like I am being forced to use JSON as that seems to be the only method to get data from a remote web server but the learning curve seems horrendously steep. I can't even make head nor tail of POMAX's guide and I have looked all over the web and can't find anything simpler. They all assume more knowledge of javascript than I have and none of them have a working zip file containing all the code and a sample JSON file to play with.
Seems I have to create some javascript code to pass the object to the processing js pde. Im really surprised that there arent more working examples out there
Can anyone help with the javascript code to take the feed above and put it into my sketch. Once i have a working example I will understand far more what I am doing
Totally frustrated with the learning curve. What I want to do is pretty simple.
I want to grab this feed
http://api.thingspeak.com/channels/5384/feed/last.json?status=true
and get the data into this simple test sketch which i will run in processing.js
- float PanelTemp;
float PoolTemp;
int ControllerMode;
int SetTempInc;
int PanelCriticalTemp;
long CumulativePumpRuntime;
int PumpsOnOff;
String StatusText;
void setup()
{
}
void draw()
{
GetWebData(10.0,11.0,1,2,3,1234567,6,"This is a test");
println(PanelTemp + ", " + PoolTemp + ", " + ControllerMode + ", " + SetTempInc + ", " + PanelCriticalTemp + ", " + CumulativePumpRuntime + ", " + PumpsOnOff + ", " + StatusText);
}
void GetWebData(float field1, float field2, int field3, int field4, int field5, long field6, int field7, String status)
{
PanelTemp = field1;
PoolTemp = field2;
ControllerMode = field3;
SetTempInc = field4;
PanelCriticalTemp =field5;
CumulativePumpRuntime = Long.valueOf(field6);
PumpsOnOff= field7;
StatusText = status;
}
I have been playing around with formatting the data based on a local CSV file version. I would prefer to grab the CSV from the web server but it seems I can't do that with loadStrings() as it only works for a local file (Or file on the same domain).
It looks like I am being forced to use JSON as that seems to be the only method to get data from a remote web server but the learning curve seems horrendously steep. I can't even make head nor tail of POMAX's guide and I have looked all over the web and can't find anything simpler. They all assume more knowledge of javascript than I have and none of them have a working zip file containing all the code and a sample JSON file to play with.
Seems I have to create some javascript code to pass the object to the processing js pde. Im really surprised that there arent more working examples out there
Can anyone help with the javascript code to take the feed above and put it into my sketch. Once i have a working example I will understand far more what I am doing
1