Skip to content

Decoding non-valid JSON silently quits basil scripts #148

Open
@trych

Description

@trych

Hi there,
a student of our class just found this bug.

Take a non-valid JSON file (closing square bracket missing):

[
  {
    "id": 1,
    "level": 0,
    "centroid": 0,
    "bass": 0,
    "lowMid": 0,
    "mid": 0,
    "highMid": 0
  },
  {
    "id": 2,
    "level": 0,
    "centroid": 941.1855468750001,
    "bass": 0,
    "lowMid": 0,
    "mid": 1.6990291262135921,
    "highMid": 0
  }

and try to decode it with basil.js:

//@includepath "~/Documents/;%USERPROFILE%Documents";
//@include "basiljs/basil.js";

function draw() {
  b.clear(b.doc());

  //JSON
  var jsonString = b.loadString("buggy.json");

  var jsonData = b.JSON.decode( jsonString );

  b.println("Hello world!"); // --> does not print

  b.rect(0, 0, 100, 100); // --> does not draw

}

b.go();

basil does not throw any error but instead silently stops executing any commands after the b.JSON.decode().

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions