Resource classes push their data into the protected "fields" property, making it difficult to extract the data.
It would be nice if the Resource class could make use of PHP's "__serialize()" magic method to bring that data out to, at a minimum, a PHP array.
An alternative might be just to create a "toJSON()" method on the Resource class and provide real JSON output.