Return JSON if return value is Hash
Group logic together into #prepareHeaders!