05-31-2018, 01:43 PM
There's really no magical/easy way to turn a platform-specific array or object in memory into something persistent (via document data) that can later be properly restored to memory on any given platform.
In general, you'll have to fill out an Illustrator document dictionary with key/value pairs that represent members in a given object. If your object has subobjects then your Ai dictionary will have to utilize subdictionaries.
Again, in general, you'll have to loop over an array and store each item in an Illustrator document array. If your array stores objects then your Ai array will have to store Ai subdictionaries.
In either case, you'll have to read the data out of the Ai dictionary or array and construct the proper type of object or array in memory later on.
Either container type can store just about any primitive type. If you want to store something more complicated than a primitive in an Illustrator container type, I recommend using the hdi::core:refData hierarchy of classes. You can stringify the data in a PrefData-based object to a JSON string, and of course the aforementioned Illustrator container types can store strings. Later, when reading said strings, you can create a PrefData object from parsing the JSON string.
In general, you'll have to fill out an Illustrator document dictionary with key/value pairs that represent members in a given object. If your object has subobjects then your Ai dictionary will have to utilize subdictionaries.
Again, in general, you'll have to loop over an array and store each item in an Illustrator document array. If your array stores objects then your Ai array will have to store Ai subdictionaries.
In either case, you'll have to read the data out of the Ai dictionary or array and construct the proper type of object or array in memory later on.
Either container type can store just about any primitive type. If you want to store something more complicated than a primitive in an Illustrator container type, I recommend using the hdi::core:refData hierarchy of classes. You can stringify the data in a PrefData-based object to a JSON string, and of course the aforementioned Illustrator container types can store strings. Later, when reading said strings, you can create a PrefData object from parsing the JSON string.