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
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 ?
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]);
I beg your pardon, you need to be careful what you write! Thank you! The code works
Copy link to clipboard
Copied
i tested it on a windows machine same issue
any help would be appreciated
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...?
Copy link to clipboard
Copied
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)
.
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?
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
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]);
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 .
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.
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
Copy link to clipboard
Copied
Works fine here, multiple Windows machines.
https://shared-assets.adobe.com/link/8cee52b0-3c58-4e01-48f5-a3c34810611a
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
Copy link to clipboard
Copied
That error is on line 9, which suggests that lines 6 or 7 may have succeeded.
Copy link to clipboard
Copied
I beg your pardon, you need to be careful what you write! Thank you! The code works
Copy link to clipboard
Copied
But an object that works in AE will not work in PP. This is true. For RR, the data needs to be changed