Java Code Examples for org.springframework.http.converter.json.GsonFactoryBean

Following code examples demonstrate how to use org.springframework.http.converter.json.GsonFactoryBeanfrom spring-framework. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use org.springframework.http.converter.json.GsonFactoryBeanand various code implementation of this class.

    public String toJSON(ErrorResponse errorResponse) {
        GsonFactoryBean gsonFactoryBean = new GsonFactoryBean();
        gsonFactoryBean.setPrettyPrinting(true);
        gsonFactoryBean.afterPropertiesSet();
        Gson gson = gsonFactoryBean.getObject();
        return gson.toJson(errorResponse);
    } 


Advertisement
Javadoc
A FactoryBean for creating a Google Gson 2.x Gson instance. @author Roy Clarkson @author Juergen Hoe

ller @since 4.1

Read More
Advertisement