Activity › Forums › Adobe After Effects Expressions › Read a json-file
-
Read a json-file
Posted by Jacob Danell on May 20, 2014 at 10:21 pmHi! I want to read a json-file and use it’s data in different dropdown-menus. I have searched a lot now but so far the only way I have found a way to read the file is to use eval() but also bin told not to use it, so how is the most easy way to get the data out from an json-file?
Eve Weinberg replied 9 years, 8 months ago 4 Members · 7 Replies -
7 Replies
-
Dan Ebberts
May 20, 2014 at 11:01 pm>the only way I have found a way to read the file is to use eval()
That’s the way I’ve done it.
Dan
-
Jacob Danell
May 29, 2014 at 7:18 pmAfter working with my script I found out that eval wasn’t the best solution, it’s much better to use JSON.parse. That way you really read the json as it’s suppose to be read. Eval only converts the code into readable javascript-code so it’s not json at all.
-
Dan Ebberts
May 29, 2014 at 7:28 pmHow did you get that to work? As far as I know, ExtendScript is based on v3 of ECMA-262 and JSON.parse() was added after that.
Dan
-
Jacob Danell
July 14, 2014 at 5:20 pmI added the code from json2.js (https://github.com/douglascrockford/JSON-js/blob/master/json2.js) into my jsx file. This only worked for AE5+
-
Shawn Baden
September 29, 2014 at 5:52 pmOnce you’ve used JSON.parse() how do you call/retrieve the data?
I’m using something like: obj.itemOne[0].item but am getting undefined
-
Eve Weinberg
August 31, 2016 at 8:31 pmCould anyone on this thread explain this a bit further to a new JSON user?
I have a json file with a key:value pairing of some text. A few questions:1) Where is he jsx folder that I should throw the script into?
2) Do I need to activate it inside AE?
3) Where do I write the line: JSON.parse()What else do I need to know to get this up and running?
Thanks,
Eve
Reply to this Discussion! Login or Sign Up