use of org.springframework.http.converter.json.MappingJacksonHttpMessageConverter in project robospice by stephanenicolas.
the class JacksonSpringAndroidSpiceService method createRestTemplate.
@Override
public RestTemplate createRestTemplate() {
RestTemplate restTemplate = new RestTemplate();
// web services support json responses
MappingJacksonHttpMessageConverter jsonConverter = new MappingJacksonHttpMessageConverter();
final List<HttpMessageConverter<?>> listHttpMessageConverters = restTemplate.getMessageConverters();
listHttpMessageConverters.add(jsonConverter);
restTemplate.setMessageConverters(listHttpMessageConverters);
return restTemplate;
}
use of org.springframework.http.converter.json.MappingJacksonHttpMessageConverter in project spring-data-document-examples by spring-projects.
the class RestTemplateActivity method onCreate.
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView view = new TextView(this);
view.append("Running tests...\n\n");
setContentView(view);
try {
List<HttpMessageConverter<?>> converters = new ArrayList<HttpMessageConverter<?>>();
converters.add(new MappingJacksonHttpMessageConverter());
RestTemplate restTemplate = new RestTemplate();
restTemplate.setMessageConverters(converters);
Map response = restTemplate.getForObject("http://127.0.0.1:5984", Map.class);
view.append(response.toString());
/*
URL url = new URL("http:/127.0.0.1:5984");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
List<String> lines= new ArrayList<String>();
while((line = reader.readLine()) != null){
lines.add(line);
}
reader.close();
view.append(lines.toString());*/
view.append("all ok!");
} catch (Exception e) {
view.append(e.toString());
Log.e("rest-template", "this is bad", e);
}
}
use of org.springframework.http.converter.json.MappingJacksonHttpMessageConverter in project spring-data-document-examples by spring-projects.
the class CouchDbConfig method restTemplate.
@Bean
public RestTemplate restTemplate() {
RestTemplate restTemplate = new RestTemplate();
List<HttpMessageConverter<?>> converters = new ArrayList<HttpMessageConverter<?>>();
//converters.add(new MappingJacksonHttpMessageConverter());
converters.add(new CouchDbMappingJacksonHttpMessageConverter());
restTemplate.setMessageConverters(converters);
return restTemplate;
}
Aggregations