Okie dokie, this is getting too difficult, so while @ego-lay_atman-bay was writing his solution, I worked out with my own, though his solution is easier.
parallel-run a "simple" script that check if a ws.msg.new is true on my WebSocket variable and if ws.msg even exists.
if we got a new message, parse up the spicy JSON object from a string to table, defaulting to a string if failed.
Oh, by the way, in case you want it, here's a recursive function that turns a list of lists into snap lists.
function toSnapList(arr) {
let newArr = []
for (let item of arr) {
if (Array.isArray(item)) {
item = toSnapList(item)
}
newArr.push(item)
}
return new List(newArr)
}
// ...
case 'json':
this.assertType(list, 'list');
if (list.canBeJSON()) {
return list.asJSON();
}
throw new Error(
localize('unable to convert to') + ' ' + localize('JSON')
);
// ...
So really I can just new List(...).toJSON()
edit: for the other way 'round
Process.prototype.reportBasicTextSplit (idk why is it called that if its being directly called from split primitive) calls this.parseJSON(string), so I can just practically new Process().parseJSON(JSON.stringify({hehehe: ":stuck_out_tongue_winking_eye:"}))
But all my info was too late to gain since I accidentally stumbled upon both of these ways later than when I was coding in serialization into my project where I needed to find out this useful info. Now I'll know for later...
I also realised that to call a block script you need to instantiate a Process, then do some secret black magic on it and the editor to actually call the script. Will also be knowing this for later...
Actually, if you do it in a javascript function block, the current Process object is passed in as the last argument if you have one more parameter than what is passed in with "with inputs", which can be used instead of creating your own process. For example