Skip to main content
edit2j47225339
Known Participant
Oct 3, 2019 1:19 PM UTC
Question

How to read JSON file in Premiere CEP extension?

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 is closed to new replies. Start a new post to keep the conversation going.

6 replies

edit2j47225339
Known Participant
Oct 3, 2019 2:27 PM UTC

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. 

Translate
Justin Taylor-Hyper Brew
Community Expert
Community Expert
Oct 3, 2019 9:14 PM UTC

You can just use JSON2

https://cdnjs.com/libraries/json2

and include it with

//@include 'json.js';
Translate
edit2j47225339
Known Participant
Oct 4, 2019 4:57 PM UTC
Ah, so if I understand correctly it's the way I included it with #include that didn't make it work with JSON2?
Translate
Oct 3, 2019 2:03 PM UTC

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

Translate
edit2j47225339
Known Participant
Oct 3, 2019 2:22 PM UTC
No, JSON is not supported by default. But I found a solution. I'll share it here.
Translate