String s = (o instanceof byte[] ? new String((byte[]) o) : (String) o);
if (s.charAt(0) == '{' || s.charAt(0) == '[') {
// Looks like it might be a JSON string. Use the JSON converter
for (HttpMessageConverter conv : getRestTemplate().getMessageConverters()) {
if (conv instanceof MappingJacksonHttpMessageConverter) {
o = conv.read(requiredType, new HttpInputMessage() {
public InputStream getBody() throws IOException {
Object body = response.getBody();
return new ByteArrayInputStream(
(body instanceof byte[] ? (byte[]) body : ((String) body)
.getBytes()));