Copy link to clipboard
Copied
Hi,
I am trying to get the data from JSON into Illustrator.
For that i am trying with my Javascript coding is,
#include json2.js
var jsonFile = File.openDialog("Select the JSON");
var data = JSON.parse(jsonFile);
alert(data.id);
My JSON coding is,
{
"id": 638455,
"description": "1234"
}
I got an error as "throw new SyntaxError("JSON.parse")". Can you please check and do the needful to get the data from JSON to illustrator through script.
Note: I am unable to upload the json2.js here, i have downloaded and used the json2.jx from the github.
Thanks
Asuvath
You need to read the file and pass the string to the parse method, try the following
#include "json2.js"
var jsonFile = File.openDialog("Select the JSON")
jsonFile.open("r")
var data = JSON.parse(jsonFile.read());
alert(data.id);
-Manan
Copy link to clipboard
Copied
You need to read the file and pass the string to the parse method, try the following
#include "json2.js"
var jsonFile = File.openDialog("Select the JSON")
jsonFile.open("r")
var data = JSON.parse(jsonFile.read());
alert(data.id);
-Manan
Copy link to clipboard
Copied
Thanks lot Manan. Its working Fine.