Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

How to load a local JSON using JavaScript CEP API

New Here ,
Feb 13, 2019 Feb 13, 2019

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 !

TOPICS
SDK
1.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Adobe Employee , Feb 13, 2019 Feb 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 }

Translate
Community Expert ,
Feb 13, 2019 Feb 13, 2019

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 13, 2019 Feb 13, 2019

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 13, 2019 Feb 13, 2019

Moved to Premiere Pro SDK

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Feb 13, 2019 Feb 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 }

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 15, 2019 Feb 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 15, 2019 Feb 15, 2019
LATEST

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-Re...

Thank you again !

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines