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

JSX: Intermittently getting JSON is undefined alert

Participant ,
Nov 20, 2017 Nov 20, 2017

Copy link to clipboard

Copied

Hi All,

We are intermittently getting JSON is undefined alert while converting object to string using JSON.stringify()

It gets resolved by resetting Premiere Pro preference: Configure preference settings in Premiere Pro
We want to know why and when JSON object is not available in the jsx file. Is there any way to prevent this alert?

Premiere Pro Version: 9.0.0
Extension Type: Panel

Thanks & Regards,
Meet Tank

TOPICS
SDK

Views

3.4K

Translate

Translate

Report

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

Enthusiast , Nov 22, 2017 Nov 22, 2017

meett9325076  wrote

We are intermittently getting JSON is undefined alert while converting object to string using JSON.stringify()

It gets resolved by resetting Premiere Pro preference: Configure preference settings in Premiere Pro
We want to know why and when JSON object is not available in the jsx file. Is there any way to prevent this alert?

The default ExtendScript environment does not support JSON. You can verify this yourself by opening the ExtendScript Toolkit and looking for it in the Data

...

Votes

Translate

Translate
Adobe Employee ,
Nov 20, 2017 Nov 20, 2017

Copy link to clipboard

Copied

Why are you targeting such an antique version of PPro?

The ExtendScript JSON object is provided NOT by ExtendScript, but by Adobe's own panels. I'll bet you can come up with a working implementation, bringing that JSON support into your panel.

Votes

Translate

Translate

Report

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
Participant ,
Nov 21, 2017 Nov 21, 2017

Copy link to clipboard

Copied

Bruce Bullis​, I have found an example: https://www.davidebarranca.com/2014/02/html-panels-tips-5-passing-objects-from-jsx-to-html-json/ In which: "Mind you, ExtendScript doesn’t support JSON natively so the original library must be included"

I think we should not rely on third party javascript library to add support of JSON in the extend script.

Questions:

  • Is there any plan to add support of JSON in the extend script itself?
  • Is there any other elegant way to include JSON in the jsx file other than the third party javascript?

Thanks,

Meet

Votes

Translate

Translate

Report

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 ,
Nov 21, 2017 Nov 21, 2017

Copy link to clipboard

Copied

We have no plans to attempt to add JSON support to ExtendScript. We recommend doing any JSON-related work in a panel's CEP/JavaScript layer.

Votes

Translate

Translate

Report

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
Participant ,
Nov 22, 2017 Nov 22, 2017

Copy link to clipboard

Copied

Thank you Bruce Bullis. We need to convert object to string from jsx itself as a return value. Can we use third party JSON object only when existing JSON (provided by Adobe's panel) is not available?

Thanks,
Meet

Votes

Translate

Translate

Report

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 ,
Nov 22, 2017 Nov 22, 2017

Copy link to clipboard

Copied

I'm not sure; I've never done any testing of competing JSON modules.

If you're including your own JSON handling, you could conceivably name it JSON_Meet or something to avoid any potential collisions, right?

Votes

Translate

Translate

Report

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
Enthusiast ,
Nov 22, 2017 Nov 22, 2017

Copy link to clipboard

Copied

meett9325076  wrote

We are intermittently getting JSON is undefined alert while converting object to string using JSON.stringify()

It gets resolved by resetting Premiere Pro preference: Configure preference settings in Premiere Pro
We want to know why and when JSON object is not available in the jsx file. Is there any way to prevent this alert?

The default ExtendScript environment does not support JSON. You can verify this yourself by opening the ExtendScript Toolkit and looking for it in the Data Browser. By default, it won't be there. It probably will be once you attach to a running version of Premiere Pro. This is because many of Adobe's UI screens (including, it seems, something related to the preference settings flow) actually load their own JSON library into the application's ExtendScript context.

When you run ExtendScript in an application you are actually doing so in a shared context. All panels share the same global context. If you're able to use JSON by default, this is likely because some other Adobe-provided panel was run before yours was and included JSON. If you actually look at the globally loaded JSON objects in the ExtendScript environment, you'll see that there are actually several (JSON and JSON3). This is because different Adobe panels load different JavaScript JSON libraries. My guess is that different teams within Adobe are responsible for different panels and are free to choose their own.

You appear to have found yourself in a situation where you were able to start up Premiere Pro without other panels loading first. To resolve this, include your own third-party JSON library in your project (there are several free ones available, including the previously linked JSON3). Well-formatted ones automatically test for the pre-existence of the JSON APIs and will only install if one doesn't exist. We use this one.

To install it we have the following in our main JSX script:

//@include ../lib/json2.jsx

(Note that we renamed the .js file to .jsx, even though it isn't necessary.)

Effectively, you need to Polyfill the ExtendScript context with any APIs not included in the ECMAScript 3 standard.

Votes

Translate

Translate

Report

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
Participant ,
Nov 23, 2017 Nov 23, 2017

Copy link to clipboard

Copied

Thanks sberic. We need a minified version of https://github.com/douglascrockford/JSON-js/blob/master/json2.js. Where can we find that?

Votes

Translate

Translate

Report

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
Enthusiast ,
Nov 30, 2017 Nov 30, 2017

Copy link to clipboard

Copied

LATEST

meett9325076  wrote

We need a minified version of https://github.com/douglascrockford/JSON-js/blob/master/json2.js. Where can we find that?

Did a quick Google search and found this CDNJS link. See here for the minified file, but note that it does reference the sourcemap (which is also available in the CDNJS link).

Votes

Translate

Translate

Report

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