mirror of
https://github.com/jnunemaker/httparty
synced 2023-03-27 23:23:07 -04:00
Handle json parsing errors and fall back to inspect for CLI
This commit is contained in:
parent
762bb6b056
commit
60aa11a8bb
1 changed files with 3 additions and 1 deletions
|
@ -103,9 +103,11 @@ else
|
||||||
when :json
|
when :json
|
||||||
begin
|
begin
|
||||||
require 'json'
|
require 'json'
|
||||||
puts JSON.pretty_generate(response)
|
puts JSON.pretty_generate(response.parsed_response)
|
||||||
rescue LoadError
|
rescue LoadError
|
||||||
puts YAML.dump(response)
|
puts YAML.dump(response)
|
||||||
|
rescue JSON::JSONError
|
||||||
|
puts response.inspect
|
||||||
end
|
end
|
||||||
when :xml
|
when :xml
|
||||||
require 'rexml/document'
|
require 'rexml/document'
|
||||||
|
|
Loading…
Add table
Reference in a new issue