JSFiddle - React, Tailwind, and code Playground
JavaScript
var stringToParse = "{vertices:[-1.0, -1.0, -1.0, -1.0, -1.0, 0.0, 1.0, -1.0, 0.0]}";
Object.prototype.simpleParse = function() {
if (!(this instanceof String)) throw "Type mismatch";
var re = /(\w+)[^:]+:\[([^\]]+)\]/g;
var keyvalues = re.exec(this.valueOf());
var key = keyvalues[1];
var values = keyvalues[2].split(",");
var arr = [];
for (val in values) {
var currentValue = (/-?\d+(.\d+)?/).exec(values[val])[0];
arr.push(currentValue);
}
arr.pop();
ret = {};
ret[key] = new Float32Array(arr);
return ret;
}
console.log(stringToParse.simpleParse());