Skip to content

Instantly share code, notes, and snippets.

@osdrv
Created December 19, 2011 18:01
Show Gist options
  • Save osdrv/1498182 to your computer and use it in GitHub Desktop.
Save osdrv/1498182 to your computer and use it in GitHub Desktop.
Processing + json
import org.json.*;
import simpleML.*;
XMLRequest xmlRequest;
String apiHost = "http://example.com";
void setup() {
HTMLRequest req = new HTMLRequest( this, apiHost + "/data.json" );
req.makeRequest();
}
//...
void netEvent(HTMLRequest ml) {
String source = ml.readRawSource();
try {
JSONArray events = new JSONArray( source );
for ( int i = 0; i < events.length(); ++i ) {
//...
}
} catch ( Exception e ) {
//...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment