OmniAutomation / JXA - Storing JSON in iCloud to share between iOS and macOS

I’m writing a script in Omni’s version of JXA to create projects. The nice thing is that the plugin can be run on both my phone and my Mac.

Right now the template is hardcoded, but I want to store it on iCloud in json format so I can have multiple templates.
I have a few questions I can’t seem to find the answer to:

  1. if I want the data to be accessible in both the Mac and the phone, am I correct in assuming it has to live within the OmniFocus directory of iCloud (because of sandboxing on iOS)?
  2. is there a standard library, code snippet, method that people use to store retrieve json in JXA. I’m confused between filewrappers, etc …

Thanks!

1 Like

I would expect you would just be using the text file approaches listed in the automation documentation. Then using JSON.stringify() to convert the object to string for saving, and JSON.parse() to convert it back.

I would expect so, but I don’t know for sure. However, would it not be the most logical place to hold it in any case?

Thanks for the link.

I’m surprised there aren’t more examples of using JSON as a sort of semi permanent storage. Which leads me to think I’m missing something absolutely obvious as an answer to my problem …

As for iCloud, yes and no. Eventually I want the data to be used in a workflow that will encompass Trello, omniplan and Omnifocus at least :smiley: … but baby steps.