I'm currently trying to create a JSONObject from at String. In Processing 2.0 beta 8 JSONObject is native, which is awesome. The problem is that it seems like there is a major error in this library. When I try to create a JSONObject from the below String I get the following error message:
Exception in thread "Animation Thread" java.lang.RuntimeException: JSONArray initial value should be a string or collection or array
I know the JSON is valid because it's generated from the CKAN platform and this page also says it's valid:
http://jsonlint.com/
The problem is that the native JSON library seems to not understand if there is a JSONArray inside a JSONObject. This is of course wrong. I have been trying to Google around, but it doesn't look like anyone else has experienced this problem. Does anyone have any ideas for solving this issue?
I am creating a custom library, where I need to use the serial library. I am doing it in Eclipse.
What i want to do is:
I want the custom library to handle serial connection, so that part will essentially be invisible to users of the library. The custom library should read serial data, format it and via an event send it to the parent (PApplet - the actual Processing sketch). This means that it should not be necessary to import serial in the main sketch.
The main sketch:
import dulRadio.*;
import processing.opengl.*;
Integer[] res=null;
void setup() {
frameRate(60);
size(screen.width, screen.height,OPENGL);
//Ani.init(this);
new DULRadio(this, "COM79", 9600, 13);
}
void draw() {
background(125);
//text("received: " + inString, 10,50);
if(res!=null && res.length==4){
float m=map(res[1],-255,255,0.5,1.5);
float m2=map(res[2],-255,255,0.5,1.5);
translate(width/2, height/2);
pushMatrix();
rotateZ(PI*m);
rotateX(PI*m2);
box(100);
popMatrix();
}
}
void dulEvent(DULRadio d){
res=d.getDULData();
}
My custom library:
package dulRadio;
import java.lang.reflect.Method;
import processing.core.*;
import processing.serial.*;
public class DULRadio{
Method dulRadio;
PApplet parent;
Serial s;
int delimiter;
Integer[] res=null;
public DULRadio(PApplet parent, String comport, int baud, int del) {