From 7c7b01664315f8f3336a6296d4db363f6ecbaa83 Mon Sep 17 00:00:00 2001 From: Karishma Chadha Date: Wed, 28 Feb 2018 11:52:22 -0500 Subject: [PATCH] scratch-parser expects json string... --- src/virtual-machine.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/virtual-machine.js b/src/virtual-machine.js index 4734623c6..2dbfe5d46 100644 --- a/src/virtual-machine.js +++ b/src/virtual-machine.js @@ -245,7 +245,9 @@ class VirtualMachine extends EventEmitter { deserializer = sb3; validatedProject = possibleSb3; } else { - validate(json, (err, project) => { + // scratch-parser expects a json string or a buffer + const possibleSb2 = typeof json === 'object' ? JSON.stringify(json) : json; + validate(possibleSb2, (err, project) => { if (err) { const errorMessage = `The given project could not be validated, parsing failed with error: ${JSON.stringify(err)}`;