Posted by nbaum5 1 year 16 weeks ago
I'm getting an error "Unable to load Json data" when trying to load the json file with getTreeFromFile. The data is not parsing into a hash. Should I be using a parser other rather than JSON.parse? Could the data file be corrupt somehow?
Thanks for any help!




Posted by daniel.hunt 1 year ago
Mobile Grandmaster
Have you verified the file permissions of the JSON file itself? Does your script have the right to read from it?
Daniel HuntdotMobi
Posted by nbaum5 1 year ago
Yes. I'm on Windows. I can read from the file and load its content just fine.
From the ruby command line, I do the following:
file = File.open(filename, 'r')
json = f.readlines.to_s
hash = JSON.parse(json)
Here is where it fails:
hash.kind_of?(Hash)
=> false
Posted by nbaum5 1 year ago
obviously "json = f.readlines.to_s" should read: "json = file.readlines.to_s"
Posted by nbaum5 1 year ago
Needed to use yajl-ruby instead of JSON.