plamoni/SiriProxy — Issue #227: JSON.parse fails
Author: jstockton
Created: 2011-12-29 17:00:33+00:00
State: open

I'm trying to use the Viper Smart Start plugin which parses a response from a PHP page. Everything works up until the script tries to parse the result from the PHP page and I haven't been able to figure out why it is failing. I know that the openuri is working because I am able to start my car and have confirmed that I do get a result from the PHP page so Im pretty confident its something to do with JSON.parse. Here are a couple of lines from the script:

status = JSON.parse(open(URI("#{self.url}?action=#{viper_command}")).read)
...
...
if(status["Return"]["ResponseSummary"]["StatusCode"] == 0)

I put some debug statements right after the call to JSON.parse and the code gets there, but as soon as it tries to access the status object, Siri just hangs and has to be manually stopped since it never reaches request_completed. Whats strange is that I have been able to take some of the code and run it irb and I can see the value of status["Return"]["ResponseSummary"]["StatusCode"]. Any ideas why parsing fails in the script but not in irb?