Skip to content

Instantly share code, notes, and snippets.

@niittymaa
Created February 9, 2017 13:39
Show Gist options
  • Save niittymaa/eb096af32f18538d06d4ae85af448535 to your computer and use it in GitHub Desktop.
Save niittymaa/eb096af32f18538d06d4ae85af448535 to your computer and use it in GitHub Desktop.
Function for reading JSON files into Indesign
/*
extended javascript for
Adobe Indesign 5.5
by
PDXIII
http://about.me/PDXIII
Honestly: It's from fabiantheblind, but I typed it ;-)
*/
main();
function main(){
var myJSONobject;
// get the textfile
var filepath = "~/Desktop/Design/FontList.json";
var fontList = File(filepath);
alert(fontList);
var content;
if(fontList != false){
fontList.open('r');
content = fontList.read();
myJSONobject = eval("{" + content + "}");
alert(myJSONobject.length);
fontList.close(); // always close files after reading
}else{
alert("Bah!");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment