Parsing JSON in adobe illustrator extended panel
I currently have two files.
A js file "myjs.js" and a jsx file "myjsx.jsx"
I pass some data and call a method in myjsx.jsx file like so:
const someData = ['john', 'bar', 'son', 'datto'];
csiRun.evalScript(`setupPlateTemplate('${someData}')`);I then can view this data in my jsx file.
function setupPlateTemplate(orderData) {
alert( JSON(orderData) );
} This alerts a full string if I try to do this: alert (JSON(orderData[0])) I get the alert of '"' since it's reading it as a string I only get the first character which is ".
I try this alert (JSON.parse(orderData)) but nothing happens. Nothing as in no error or anything.
I'm using this library: json2.jsx found here.
I tried json.stringify on the js before I send it and that doesn't work either. Any idea what I'm doing wrong?
