Class: Twurl::JsonFormatter
- Inherits:
-
Object
- Object
- Twurl::JsonFormatter
- Defined in:
- lib/twurl/request_controller.rb
Class Method Summary collapse
Class Method Details
.format(string) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/twurl/request_controller.rb', line 34 def self.format(string) json = JSON.parse(string) (json.is_a?(Array) || json.is_a?(Hash)) ? JSON.pretty_generate(json) : string rescue JSON::ParserError, TypeError string end |