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

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

1.7K

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 2 Correct answers

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]); 

Votes

Translate

Translate
Contributor , Oct 25, 2022 Oct 25, 2022

I beg your pardon, you need to be careful what you write! Thank you! The code works

Votes

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

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 ,
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...?

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
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)

 

.

 

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 ,
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?

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

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 ,
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]); 

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

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

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

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

Copy link to clipboard

Copied

Works fine here, multiple Windows machines. 

 

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

 

 

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
Contributor ,
Oct 25, 2022 Oct 25, 2022

Copy link to clipboard

Copied

Hi, this code doesn't work for me either.
This is not the first time I've come across the fact that it works for you, but it doesn't work for me

Libraries panel open

Harchenko_0-1666708263556.pngHarchenko_1-1666708276529.png

 

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 ,
Oct 25, 2022 Oct 25, 2022

Copy link to clipboard

Copied

That error is on line 9, which suggests that lines 6 or 7 may have succeeded.

 

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
Contributor ,
Oct 25, 2022 Oct 25, 2022

Copy link to clipboard

Copied

I beg your pardon, you need to be careful what you write! Thank you! The code works

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
Contributor ,
Oct 25, 2022 Oct 25, 2022

Copy link to clipboard

Copied

LATEST

But an object that works in AE will not work in PP. This is true. For RR, the data needs to be changed

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