Looping through JSON properties

for the first json

here { … }} is missing I think

and the next data is the name of the next data block.

I tried to do a while loop for that.

Chrisir


// The following short JSON file called "data.json" is parsed 
// in the code below. It must be in the project's "data" folder.



JSONObject json;

void setup() {

  size(222, 333); 

  json = loadJSONObject("data.json");

  JSONObject id = json.getJSONObject("blocks");

  println(id );
  println(id.size() );



  JSONObject animal1 = id.getJSONObject("vJb19r)WPw88AL7K#^ZI"); 
  println(animal1);

  String species = animal1.getString("opcode");
  println(species);

  println("==================================================================");

  String next1 = animal1.getString("next");
  println(next1);

  boolean abort=false; 
  while (next1!=null  &&  !abort) {
    // load full item
    animal1 = id.getJSONObject(next1);
    println(animal1);

    species = animal1.getString("opcode");
    println(species);

    if (!animal1.isNull("next")) 
      next1 = animal1.getString("next");
    else abort = true;
  }
}