Skip to main content
edit2j47225339
Known Participant
October 3, 2019
Question

How to read JSON file in Premiere CEP extension?

  • October 3, 2019
  • 2 replies
  • 6934 views

I've been working on a custom tools CEP panel for premiere at our studio. I've learned a lot about extendscript over the last year and our panel is getting pretty neat.

 

Now I want to add functionality using ecternal JSON files exported from our planner software. What I want to do is read names from the JSON file that will be used to create new sequences with those names in Premiere.

 

My problem is that I can't figure out how to read the JSON files. I've been reading about the fact that extendscript doesn't support JSON by default. Including the json2.js file (like I did in one of my After Effects scripts) doesn't seem to work in Premiere.

 

Hopefully someone can help me in the right direction, thanks!

This topic has been closed for replies.

2 replies

edit2j47225339
Known Participant
October 3, 2019

I found a solution. To get some JSON functionality into premiere CEP, you need to include this json.jsx in your panel's main jsx file: https://github.com/indiscripts/extendscript/tree/master/JSON

 

In my panel's Premiere.jsx i have this code and it works perfect:

#include "json.jsx";

var jsonFile = File(pathToJSONFile);
jsonFile.open('r');
var content = jsonFile.read();
jsonFile.close();

contentObj = JSON.eval(content);

Now 'contentObj' is an object with all the data from the JSON file. 

Justin Taylor-Hyper Brew
Community Expert
Community Expert
October 3, 2019

You can just use JSON2

https://cdnjs.com/libraries/json2

and include it with

//@include 'json.js';
edit2j47225339
Known Participant
October 4, 2019
Ah, so if I understand correctly it's the way I included it with #include that didn't make it work with JSON2?
October 3, 2019

Can't you use the standard javascript JSON.parse()? 

edit2j47225339
Known Participant
October 3, 2019
No, JSON is not supported by default. But I found a solution. I'll share it here.