Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript adobe Illustrator JSON not defined - decoding JSON encoded clipboard data

I am trying to take data that has been written and JSON encoded to the clipboard and make them into an object for an illustrator script. the use of this is to find copy a product size and then using having illustrator open a certain template and then placing in the job name and job number where needed.

when I run the script in illustrator it gives me this message :

Error 2: JSON is undefined. Line:1 -> var CLipboard = JSON.parse(app.paste());

//what I need to do
var Clipboard =JSON.parse(app.paste());

//example of what i am looking for 
/*var Clipboard = {jobNumber:  "8675309",
  accountName: "sample Account Name",
  tentSize:  "10X10 logoTENT",
  roof_color:  "DarkBluePoly"
};*/

 //example of what the clipboard data is used for
var folder = new Folder(
  "~/desktop/" + Clipboard.accountName + " " + Clipboard.jobNumber
);

1 Answers

what i ended up doing was finding a JSON api from https://cdnjs.com/libraries/json2 and putting it in the same folder and then using #include 'json2.min.js' I was able to JSON.Parse with no problem!


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!