Skip to main content
Participant
February 13, 2019
Answered

How to load a local JSON using JavaScript CEP API

  • February 13, 2019
  • 6 replies
  • 2176 views

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.
Correct answer Bruce Bullis

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
February 13, 2019

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 }

Participant
February 15, 2019

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.

Participant
February 15, 2019

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 !

Peru Bob
Community Expert
Community Expert
February 13, 2019

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

Participant
February 13, 2019

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

Ann Bens
Community Expert
Community Expert
February 13, 2019

Moved to Premiere Pro SDK