scratch-parser/lib/parse.js

18 lines
606 B
JavaScript
Raw Normal View History

2016-03-18 19:51:40 -04:00
/**
* Converts string from unpack method into a project object. Note: this method
* will be expanded greatly in the future in order to support the Scratch 1.4
* file format. For now, this is nothing but an (awkward) async wrapper around
* the `JSON.parse` function.
* @param {string} input Stringified JSON object
* @param {Function} callback Returns error or parsed JSON object
* @return {void}
2016-03-18 19:51:40 -04:00
*/
module.exports = function (input, callback) {
2016-03-18 19:51:40 -04:00
try {
var result = JSON.parse(input);
callback(null, result);
2016-03-18 19:51:40 -04:00
} catch (e) {
return callback(e.toString());
}
};