It's probably better to raise some kind of exception here if response type was json but decoding of it failed, rather than returning the non-decoded json (a few lines down).