extendscript-json

Adobe ExtendScript compatible JSON library

Usage no npm install needed!

<script type="module">
  import extendscriptJson from 'https://cdn.skypack.dev/extendscript-json';
</script>

README

Overview

extendscript-json provides a standalone JSON library that works with Adobe ExtendScript.

Installation

Simply install it like any other npm package.

npm install extendscript-json

Add the following to any ExtendScript (*.jsx) file where JSON availability is desired.

var Global = Global || {};
Global.rootPath = new File($.fileName).parent;
$.evalFile(Global.rootPath + '/node_modules/extendscript-json/index.jsx');

Usage

var serialized = JSON.stringify({"a": 1, "test it":[1,'2']});
var parsed = JSON.parse(serialized);
parsed.a; //=> 1
parsed['test it']; //=> [1,"2"]

JSON.stringify('[bad json'); //=> parse error

Testing

npm test or test/run.

Output should look like:

me@host> test/run
2020-03-12T14:17:21|INFO|***************************
2020-03-12T14:17:21|INFO|Jasmine ExtendScript Runner
2020-03-12T14:17:21|INFO|***************************
2020-03-12T14:17:22|WARN|To prevent odd errors, usually methods not being defined, login into Adobe Creative Cloud and verify all modal dialog boxes are closed. If tests are not running as expected, try restarting the application.
2020-03-12T14:17:22|INFO|Loading all specs in /Users/me/projects/extendscript-json/test/spec
2020-03-12T14:17:24|INFO|26 specs, 0 failures
2020-03-12T14:17:24|INFO|Finished in 0.016 seconds

NPM Release Tasks

  1. Update package.json version number
  2. npm install to update package lock.
  3. Ensure tests pass.
  4. Update CHANGELOG.md with changes since last release.
  5. Check them all into the repository.
  6. git tag -a <version> -m <version>; git push --tags
  7. npm publish to deploy the release to npm.

Thanks

A big thank you to @douglascrockford for making and maintaining the JSON2 library.