Convert JSON String Variable to JSON object using JXA?

Got it. Just two small issues.

  • on the JXA side, the only issue is making sure that .getvariable is all lower-case.
  • on the JSON side, you are just hitting the difference between the relative flexibility of JS code and the particular requirements of standard parseable JSON. In short, object keys don't need quotes (single or double) in JS code, but the JSON standard does require quotes, and specifically double quotes around object keys.

i.e. apart from editing getVariable to getvariableyou just need to ensure that the upstream process is producing conformant JSON.

So this should work:


Read json.kmmacros (18.5 KB)

1 Like