I have to work with a Ruby script that is dependent on a Gem. When the script is executed a JSON object is returned.
I am successfully executing the script using the following code.
<?php
$ruby = 'ruby ruby/teams.rb';
$res = system($ruby);
var_dump(json_decode($res, true));
The following is an example response from ruby/teams.rb
{"status"=>"active", "teamId"=>"XPLFKS59PK" }
My problem is that this printed directly to the screen and is not capture in the variable $res
. When using var_dump(json_decode($res, true))
I get null
.
What I would like to be able to do is capture the JSON response in the $res
variable so I can convert to an array and worth with the data.
Any ideas if this is possible?