I was wondering if it is possible to extract an Array from a String using pure native javascript:
I tried using JSON.parse() and indexOf() but the return string has dynamic values in it making it hard to identify which first section is a whole of an array string format.
I was able to get it work using
let value = result;
value=value.substr(value.indexOf("["),value.indexOf("generic653")+1);
let splitter = JSON.parse(splitt);
console.log(splitter);
But right after a while when the values starts to change I get a parse error saying it's not an array.
Example string looks like this:
let val = '>\n} som7833e)) 6585[["val.s","g.m",[1125,null,null,
["hsg.s",null,null]]\n,true,true,false,"generic653"]], 58["https",null,false]';
/* sometimes this: */
let val2 = ')[} eval668525)) 8895222["gt.m","g.m",[1125,null,null,
["hsg.s",null,null]]\n,true,true,false,"generic611",["https",null,false]]\n\n 7889[jyu.b,null,false,true]';
I want.
[["val.s","g.m",[1125,null,null, ["hsg.s",null,null]]\n,true,true,false,"generic653"]]
and
["gt.m","g.m",[1125,null,null,["hsg.s",null,null]]\n,true,true,false,"generic611",["https",null,false]]
only here so i could JSON.parse() it and use it as an array. I even tried using try catch so that if it returns an error it would change the indexOf("generic653") to indexOf("]]") but as It is said the values are dynamic and there is no way i could trap all 15 thousand++ of them.
'['and everything after the last']', you might be left with a parsable json.