DESPERATE: how to load external JSON data?

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
lunelson
Posts: 18
Joined: March 26th, 2006, 1:58 am

OK,

So I'm trying to hack the FCP to AE workflow that Dale Bradshaw blogged about...

I've got my Final Cut XML parsed in to JSON using some PHP functions from IBM's developer pages...I just parsed the entire file rather than trying to create routines for specific elements. I figure I'll take the elements I want once I'm working with it as a Javascript Object.

Now I just need to get AE to load and evaluate the output file.

Can anyone tell me what command is necessary to load a JSON object in to AE from an external text file?

My JSON file is called "jsonOutput.js" (the naming can easily be changed) and it's at the root level of my drive, and it is of course a large data object starting with a curly bracket and going in to a long series of nested objects and arrays within it.

It starts like this: "{"xmeml":{"@attributes":{"version":"1"},"sequence":..."

..and goes on for pages.
I tried this for instance:

var jsonFile = new File("/jsonOutput.js");
jsonFile.open("r");
var jsonData = eval( jsonFile.read() );
jsonFile.close();

alert(jsonData.xmeml.sequence.name);


...which didn't give me an error at first, until I added that last line to see if I could actually get some data from it. So obviously this is wrong -- it's probably not actually reading the file at all. I'm sure I don't have the right method here and I trying to search the stupid Scripting Guide PDF for words like "load" and "file" is just ridiculous. Any ideas?

Everywhere I look for info about JSON it says you should be able to just do eval() on the file, but that is for Javascript in HTML pages and in this case I don't know what the equivalent is...

Please help!! I would really like to get this thing working!!
bradshaw1965
Posts: 98
Joined: March 14th, 2006, 2:16 pm
Location: Atlanta, GA
Contact:

hey lunelson,

What I'd do is start with a very simple fcp.xml file. a sequence with one clip and do the parse to simplify the contents of the file. I'd also eliminate the file loading part for now, just copy/paste the simplified string of text into a variable while you are developing, so you can attack one problem at a time, like in the example.

It sounds like your being a little ambitious with what your trying to put into your .json file. If your using the IBM stuff to convert the whole xml file to a .json file you are probably parsing a lot of data you won't use and the dot syntax i.e. jsonData.xmeml.sequence.name is probably not exactly how the parsed data structure ended up .

What's the error message you get when you add the alert? if you back out and do something like alert(JsonData.xmeml) does it still think it's an object?

After you do the above if you want to send me a copy of the .json file at dale(at)creative-workflow-hacks(dot)com, I'll take a look when I can spare some cycles.

best,

Dale
Dale Bradshaw
Technology Director | Primal Screen
creative-workflow-hacks.com
Atlanta, GA
austin
Posts: 9
Joined: June 21st, 2005, 2:08 pm

I'm doing something similar wth JSON, and I just ended up adding my objects to the top of my JSX file with PHP....
Post Reply