json on premier cep Parsing issue

Community Beginner ,
Jul 09, 2021 Jul 09, 2021

Copy link to clipboard

Copied

 

hi , 
i'm trying to parse array from js to jsx 
the pasring works Great with Aftereffects CEP
however in Premier pro it doesn't work if the data came from

JSON.stringify() it does n't work 


i simplified the code to those lines thisis .jsx 

#include 'json2.js';


function jsontest( ) {
    var randomarray = [3,5,7] ; 
    var arraystrinfied = JSON.stringify(randomarray) ;
    var myJSON = '["shark","fish","dolphin"]' ;
    var obj = JSON.parse(arraystrinfied);    // this doesn't work 
    //var obj = JSON.parse(myJSON);       this works just fine 
    alert(obj[1]); 

}

note that the same code above works fine in After effects 
what is it i'm missing ? 

TOPICS
Error or problem, SDK

Views

104

Likes

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

Adobe Employee , Jul 12, 2021 Jul 12, 2021
I have confirmed that, in PPro, when the Libraries panel is not open, none of the JSON calls above work correctly. I have also confirmed that the code below (slightly modified from your original), DOES succeed in PPro. var randomarray = [3,5,7] ; var arraystrinfied = JSON.stringify(randomarray) ; var myJSON = '["shark","fish","dolphin"]' ; var obj = JSON.parse(myJSON); alert(obj[1]);

Likes

Translate

Translate
Community Beginner ,
Jul 10, 2021 Jul 10, 2021

Copy link to clipboard

Copied

i tested it on a windows machine same issue 
any help would be appreciated

Likes

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 ,
Jul 11, 2021 Jul 11, 2021

Copy link to clipboard

Copied

> the pasring works Great with Aftereffects CEP

I see that you're including Doug Crockford's json2.js, which is good, because...the JSON object available via ExtendScript is provided by the CC Libraries panel, and is only available when that panel is open. [It's unrelated to CEP.] 


Also, it seems you might need to escape at least some of the quotes in myJSON...?

Likes

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
Community Beginner ,
Jul 11, 2021 Jul 11, 2021

Copy link to clipboard

Copied

Hi @Bruce Bullis  

thank you for replying 

the thing is myJASON parsed fine no issue i put it to make things clear 

 

the problem with the stringfied array (arrayftringfied ) 

also all works fine in aftereffects both the stringfied array and the quoted one (myJASON)

 

.

 

Likes

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 ,
Jul 11, 2021 Jul 11, 2021

Copy link to clipboard

Copied

Is the CC Libraries panel open in PPro, when you're attempting to execute your script? If it isn't, arrayStrinfied will always be null, right?

Likes

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
Community Beginner ,
Jul 11, 2021 Jul 11, 2021

Copy link to clipboard

Copied

CC Libraries panel was closed and even when i open it the same heppens 
what drives me crazy that 

    var arraystrinfied = JSON.stringify(randomarray) ;

 is fine and i get a string data 
the stringify alone works fine

parse any Data work also fine and i get objects{} except
except the data came from JSON.stringify() this is only the issue 

Likes

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 ,
Jul 12, 2021 Jul 12, 2021

Copy link to clipboard

Copied

I have confirmed that, in PPro, when the Libraries panel is not open, none of the JSON calls above work correctly.

 

I have also confirmed that the code below (slightly modified from your original), DOES succeed in PPro.

 

var randomarray = [3,5,7] ; 
var arraystrinfied = JSON.stringify(randomarray) ;
var myJSON = '["shark","fish","dolphin"]' ;
var obj = JSON.parse(myJSON);    
alert(obj[1]); 

Likes

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
Community Beginner ,
Jul 13, 2021 Jul 13, 2021

Copy link to clipboard

Copied

thank you @Bruce Bullis  for making everything Clear ,
how ever 

    var randomarray = [3,5,7] ; 
    var arraystrinfied = JSON.stringify(randomarray) ;
    var obj = JSON.parse(arraystrinfied);    // this doesn't work 

this doesn't work on PPro 
sorry if Asked the wrong questions 
and thanks again . 

Likes

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 ,
Jul 13, 2021 Jul 13, 2021

Copy link to clipboard

Copied

Where, specifically, do you see it failing?

 

Your code works perfectly in PPro 15.2.0x35 (shipping), as long as the Libraries panel is open.

Likes

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
Community Beginner ,
Jul 14, 2021 Jul 14, 2021

Copy link to clipboard

Copied

i open the Libraries panel  just to be safe 

var obj = JSON.parse(arraystrinfied);    // this doesn't work 

 PPro 15.2.0 build 35 this is not working 
note that arraystrinfied came from JSON.stringify 
i tried another windows machine the same 

Likes

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
Explorer ,
Jul 14, 2021 Jul 14, 2021

Copy link to clipboard

Copied

LATEST

Works fine here, multiple Windows machines. 

 

https://shared-assets.adobe.com/link/8cee52b0-3c58-4e01-48f5-a3c34810611a

 

 

Likes

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