RuntimeException: Expected a ',' or '}'

Hi, i was working on a game, it worked when i last tested it, then i went watch video on youtube, and the sketch doesn’t work anymore, and i really do not understand at all where is the error. it just says in the console : RuntimeException: Expected a ',' or '}'
, And i can’t find any syntax error ! there is no problem in the “Errors” tab. When i launch the game, it crashes and highlights line 16 (data = loadJSONObject("data.json");). I have also tried commenting out all JSONObject things and that fixed the problem ! The thing is i will need JSON to save the game…

Can someone help me with this ? Thanks !

import processing.sound.*;
import processing.video.*;

//dice die in rain       w : 1920 h : 1080
Movie introMov;
PGraphics settings;
PImage icon;
PFont miriam;
JSONObject data = new JSONObject();
int where = 0, t1, intro, trans, set = -1;

void setup() {
  fullScreen();
  textAlign(CENTER);
  icon = loadImage("icon.png");
  data = loadJSONObject("data.json");
  miriam = loadFont("MiriamMonoCLM-Book-75.vlw");
  settings = createGraphics(width, height);
  surface.setTitle("Dice Die in Rain, which is kinda sad T-T");
  surface.setIcon(icon);
  introMov = new Movie(this, "Dice Die in Rain.avi");
  if(data.getBoolean("introWatched") == true)
    where = 1;
  else {
    //data.setBoolean("introWatched", true);
    //saveJSONObject(data, "data/data.json");
  }
  settings.beginDraw();
  settings.fill(0, 200);
  settings.rect(0, 0, width, height);
  settings.endDraw();
  introMov.play();
  fill(0);
}

void draw() {
  if(where == 0) { //intro
    image(introMov, 0, 0);
    if(introMov.time() == 79.3) {
      delay(2000);
      where = 1;
      data.setBoolean("introWatched", true);
    }
  } else if(where == 1) { //menu
    background(0, 255, 0);
    textSize(100);
    fill(0);
    text("Dice Die in Rain", width/2, height/4);
    textFont(miriam);
    text("Press any key to continue", width/2, height/2);
    textSize(32);
    text("ESC - Settings", width/7.68, 100);
    text("I - Review intro", width - width/7.68, 100);
  } else if(where == 2) {
    background(0);
    textFont(miriam);
    fill(255);
    text("BACKSPACE - exit", width/7.68, 100);
  } else if(where == 3) {
    background(255);
  } else if(where == 4) {
    background(255, 0, 0);
  }
  if(set == 1) {
    image(settings, 0, 0);
  }
}

void movieEvent(Movie introMov) {
    introMov.read();
}

void keyPressed() {
  String Key = str(key);
  Key = Key.toLowerCase();
  key = Key.charAt(0);
  if(keyCode == ESC && where != 0)
    key = 0;
  if(set == -1)
    switch(where) {
      case 0 : where = 1; introMov.stop(); break;
      case 1 : if(key == 0) where = 2; else if(key == 'i') { introMov.jump(0); delay(100); where = 0; } else where = 3; break;
      case 2 : if(key == 0) where = 1; else if(keyCode == BACKSPACE) { /*save*/ exit(); } break;
      case 3 : if(key == 0) set *= -1; break;
      case 4 : if(key == 0) set *= -1;
    }
  else {
    if(keyCode == BACKSPACE) {
      //save
      where = 1;
    } else if(key == 0)
      set *= -1;
  }
}

void mousePressed() {
  if(where == 1)
    where = 3;
}
1 Like

Oops ! Just found out i made a typo IN the json file, rather than in the sketch, the was a missing colon… Sorry ! But may this be helpful to all others who find themselves in the same problematic situation !

1 Like

The problem is almost certainly caused during parsing of the data.json file. I suspect that the file contents are no longer valid json format.

1 Like