I am working on a CEP plugin for InDesign. Since the jsx doesn't support much functions (ES3) I want to export objects from InDesign to javascript and then continue working on them there. To be able to do this I have to send JSON from the plugin, but stringifying does not work
Here is an example of a jsx-file that should return an array of graphic lines
#include './json2.jsx';
var objMain = {};
objMain.getLines = function () {
var returnObject = [];
// Loop through all graphic lines
for (var i = 0; i < app.activeDocument.graphicLines.length; i++) {
returnObject.push(app.activeDocument.graphicLines[i]);
}
return JSON.stringify(returnObject);
}
objMain.getLines();
But when I run it I get this from json2:
throw new TypeError("Converting circular structure to JSON");
I've tried iterating the object to create a new object that just contains the nested object without functions and circular dependencies, but I get "the property is not applicable in the current state" if I try to check with "typeof". I've tried many kinds of ES3-flatten methods without luck
Anyone know how to get an (entire) object JSON'ified through jsx/CEP?
I tried looping through objects removing circular dependencies, but the lack of functions in CEP/ES3 doesn't allow much