Example usage for org.springframework.http.converter.json GsonHttpMessageConverter GsonHttpMessageConverter

List of usage examples for org.springframework.http.converter.json GsonHttpMessageConverter GsonHttpMessageConverter

Introduction

In this page you can find the example usage for org.springframework.http.converter.json GsonHttpMessageConverter GsonHttpMessageConverter.

Prototype

public GsonHttpMessageConverter(Gson gson) 

Source Link

Document

Construct a new GsonHttpMessageConverter with the given delegate.

Usage

From source file:cz.cvut.jirutjak.fastimport.droid.oauth2.AccessTokenUtils.java

public static RestTemplate createRestTemplate() {
    RestTemplate template = new RestTemplate();
    Gson gson = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create();
    template.getMessageConverters().add(new GsonHttpMessageConverter(gson));

    return template;
}

From source file:au.org.ala.fielddata.mobile.service.WebServiceClient.java

/**
 * The FieldData web services tend to accept regular HTTP parameters, some of which are JSON encoded.
 * //from  w ww  . j  a  v a2 s . co m
 */
protected RestTemplate getRestTemplate() {

    RestTemplate restTemplate = new RestTemplate();
    FormHttpMessageConverter formConverter = new FormHttpMessageConverter();
    GsonHttpMessageConverter gsonConverter = new GsonHttpMessageConverter(getGson());
    formConverter.addPartConverter(gsonConverter);
    restTemplate.getMessageConverters().add(formConverter);
    restTemplate.getMessageConverters().add(gsonConverter);

    return restTemplate;
}