Properly match structured data output

Previous to this commit, if the expected_output was structured data, the
output was expected to be a string, which is not always correct.  This
commit uses the output_format parameter to determine if the output
should be compared as strings or structured data.