Skip to main content
Participant
Feb 13, 2019 11:14 AM UTC
Answered

How to load a local JSON using JavaScript CEP API

Hi,

I'm desperatly trying to load a local JSON file using CEP API.

My current code is like :

file = cep.fs.readFile('path/to/file.json');

console.log(file);

And it gives me an unusable object instead of printing the json.

What am I doing wrong ?

Thanks for helping !

This topic is closed to new replies. Start a new post to keep the conversation going.
Bruce Bullis
Bruce BullisCorrect answer
Legend
Feb 13, 2019 6:37 PM UTC

I think you're trying to print a file object, instead of the file data it contains. Here's a snippet from the CEP docs:

Adobe CEP APIs | Adobe Developer Connection

var path = “/tmp/”;

var result = window.cep.fs.readFile(path);

if (result.err == 0) {

    //success alert(result.data); // displays file content

} else { …// handle failure }

6 replies

Bruce Bullis
Bruce BullisCorrect answer
Legend
Feb 13, 2019 6:37 PM UTC

I think you're trying to print a file object, instead of the file data it contains. Here's a snippet from the CEP docs:

Adobe CEP APIs | Adobe Developer Connection

var path = “/tmp/”;

var result = window.cep.fs.readFile(path);

if (result.err == 0) {

    //success alert(result.data); // displays file content

} else { …// handle failure }

Translate
Participant
Feb 15, 2019 11:44 AM UTC

Thanks for answering.

I was doing right for accessing the file then. But :

alert(result.data);

doesn't print the file content. I'm getting an err = 3.

Where can I find docs about error messages ? Every link in the page you've sent me is error404.

Translate
Participant
Feb 15, 2019 12:25 PM UTC

I figured out, I was trying to acces it by relative path and it was from the JS script, not the Premiere Project. (Okay, stupid mistake)

Then, about the error, I've found the answer in the source code : CEP-Resources/CEPEngine_extensions.js at 5880e20b7cb2dc09e6b226f15a33165a08c0d831 · Adobe-CEP/CEP-Resources · GitHub

Thank you again !

Translate
Peru Bob
Community Expert
Community Expert
Feb 13, 2019 1:45 PM UTC

You posted in the Premiere Pro forum.  What Adobe software are you using?

Translate
Participant
Feb 13, 2019 1:54 PM UTC

Yes I posted it here because I'm making a CEP (Javascript) extension for Premiere Pro.

Translate
Ann Bens
Community Expert
Community Expert
Feb 13, 2019 2:20 PM UTC

Moved to Premiere Pro SDK​

Translate