How to write into a JSON file via input-box?

Thanks for taking your time.

The input box is actually just a an occasion where the user can type their answer.
Here’s the code I initially used, it has the input box included.

String str = "Universe size is: ";
String str2 = "The amount of stars is: "; 

int sceneCounter;

void setup(){
  size(900,400);
  sceneCounter = 0;
}
 
void draw(){
  background(0);
  fill(255);
  textAlign(CENTER, CENTER);
  textSize(25);
  
  if (sceneCounter == 0) {
    text("Give the size of the universe", width/2, 80);
    text(str,width/2, 150);
    //fill(128);
    if( over() ){
      fill(150);
    }
    rectMode(CENTER);
    rect(width/2,height-100,200,70);
  }
  
  if (sceneCounter > 0) {
    text("second page", width/2, 80);
    text(str2,width/2, 150);
    //fill(128);
    if( over() ){
      fill(150);
    }
    rectMode(CENTER);
    rect(width/2,height-100,200,70);
  }
}
 
 
boolean over(){
  return(mouseX > 350 && mouseX < 550 && mouseY > height-140 );
}

 
void keyPressed(){
  if( keyCode == DELETE || keyCode == BACKSPACE ){
    if( str.length() > 0) {
      str = str.substring(0, str.length()-1);
    }
  } else {
    if( key != CODED ){
      str += key;
    }
  }  
}
 
 
void mousePressed(){
  if( over() ){
    
    sceneCounter = sceneCounter++;
  if (sceneCounter > 3) {
    sceneCounter = 0;
  }
  println("sceneCounter " + sceneCounter++);
  
    saveIt();
  }
}
 
void saveIt(){
  String[] strs = { str, str2 };
  saveStrings( "data.json", strs);
}