Class: Goodall::Handler::Json
Instance Method Summary collapse
Instance Method Details
#parse_payload(payload) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/goodall/handler/json.rb', line 9 def parse_payload(payload) payload = if payload.class == String # assue it's a string of json begin MultiJson.load(payload) rescue MultiJson::LoadError # probably not JSON, return as-is return payload+"\n" end else payload end # detect "pretty" json by seeing if there are CRs in here if (json = MultiJson.dump(payload)) =~ /\n/ json else pretty_print(json) # json end end |