Package com.fasterxml.jackson.databind

Examples of com.fasterxml.jackson.databind.ObjectMapper


 
  @Override
  protected List<HttpMessageConverter<?>> getMessageConverters() {
   
    MappingJackson2HttpMessageConverter jsonConverter = new MappingJackson2HttpMessageConverter();
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.configure(FAIL_ON_UNKNOWN_PROPERTIES, false);
    objectMapper.configure(WRITE_DATES_AS_TIMESTAMPS, false);
    objectMapper.configure(FAIL_ON_EMPTY_BEANS, false);
    objectMapper.setSerializationInclusion(NON_NULL);
    jsonConverter.setObjectMapper(objectMapper);
   
    FormHttpMessageConverter formHttpMessageConverter = new FormHttpMessageConverter();
    formHttpMessageConverter.addPartConverter(jsonConverter);
   
View Full Code Here


    public ApiRequest(final ObjectMapper objectMapper) {
        this.objectMapper = objectMapper;
    }

    public ApiRequest() {
        this(new ObjectMapper()
                .setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES)
                .setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY)
                .registerModule(new GuavaModule())
                .registerModule(new JodaModule()));
    }
View Full Code Here

    @Mock private Input input;
    @Mock private Stream stream;

    @BeforeMethod
    public void setUp() throws Exception {
        final ObjectMapper mapper = new ObjectMapper();
        mapper.registerModule(new JodaModule());

        MockitoAnnotations.initMocks(this);

        when(objectMapper.copy()).thenReturn(mapper);
        when(stream.getId()).thenReturn("stream-id");
View Full Code Here

        }
    }

    public boolean savePreferences(String username, Map<String, Object> preferences) {
        try {
            ObjectMapper m = new ObjectMapper();
            final String body = m.writeValueAsString(preferences);
            api.path(resource.savePreferences(username)).body(new ApiRequest() {
                public String toJson() {
                    return body;
                }
            }).expect(Http.Status.NO_CONTENT).execute();
View Full Code Here

    private Thread shutdownHook;

    @Inject
    private ApiClientImpl(ServerNodes serverNodes, @Named("Default Timeout") Long defaultTimeout) {
        this(serverNodes, defaultTimeout,
                new ObjectMapper()
                        .setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES)
                        .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
                        .registerModule(new GuavaModule())
                        .registerModule(new JodaModule()));
    }
View Full Code Here

                        try {
                            // Try the HTTP API endpoint
                            final ListenableFuture<Response> future = httpClient.prepareGet("http://" + hostAndPort.getHostText() + ":9200/_nodes").execute();
                            final Response response = future.get();

                            final JsonNode resultTree = new ObjectMapper().readTree(response.getResponseBody());
                            final String clusterName = resultTree.get("cluster_name").textValue();
                            final JsonNode nodesList = resultTree.get("nodes");

                            final Iterator<String> nodes = nodesList.fieldNames();
                            while (nodes.hasNext()) {
View Full Code Here

    public static Result metrics(String classPrefix, boolean pretty) throws Exception {
        response().setContentType("application/json");
        response().setHeader("Cache-Control", "must-revalidate,no-cache,no-store");

        StringWriter writer = new StringWriter();
        JsonFactory factory = new JsonFactory(new ObjectMapper());
        final JsonGenerator json = factory.createGenerator(writer);
        if (pretty) {
            json.useDefaultPrettyPrinter();
        }
        json.writeStartObject();
View Full Code Here

@Configuration
public class TestConfiguration {

    @Bean
    public ObjectMapper objectMapper() {
        return new ObjectMapper();
    }
View Full Code Here

    );

    private final ObjectMapper mapper;

    public HystrixJacksonDecoder() {
        this(new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false));
    }
View Full Code Here

     * @param jsonView marker class to specify properties to be included during marshalling.
     *                 See also http://wiki.fasterxml.com/JacksonJsonViews
     * @param enableJaxbAnnotationModule if it is true, will enable the JaxbAnnotationModule.
     */
    public JacksonDataFormat(Class<?> unmarshalType, Class<?> jsonView, boolean enableJaxbAnnotationModule) {
        this.objectMapper = new ObjectMapper();
        this.unmarshalType = unmarshalType;
        this.jsonView = jsonView;
        this.enableJaxbAnnotationModule = enableJaxbAnnotationModule;
    }
View Full Code Here

TOP

Related Classes of com.fasterxml.jackson.databind.ObjectMapper

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.