Examples of DeserializationConfig


Examples of org.codehaus.jackson.map.DeserializationConfig

            objectMapper.setSerializationConfig(serializationConfig);
        }

        // Deserialization configuration
        if (MapUtils.isNotEmpty(deserializationFeatures)) {
            DeserializationConfig deserializationConfig = objectMapper.copyDeserializationConfig();
            for (Map.Entry<DeserializationConfig.Feature, Boolean> entry : deserializationFeatures.entrySet()) {
                DeserializationConfig.Feature feature = entry.getKey();
                boolean enabled = BooleanUtils.isTrue(entry.getValue());
                if (enabled) {
                    deserializationConfig = deserializationConfig.with(feature);
                } else {
                    deserializationConfig = deserializationConfig.without(feature);
                }
            }
            objectMapper.setDeserializationConfig(deserializationConfig);
        }
    }
View Full Code Here

Examples of org.codehaus.jackson.map.DeserializationConfig

        SerializationConfig serializationConfig =
            mapper.getSerializationConfig().withSerializationInclusion(Inclusion.NON_NULL).withAnnotationIntrospector(pair);
           //.withDateFormat(StdDateFormat.getBlueprintISO8601Format());


        DeserializationConfig deserializationConfig =
            mapper.getDeserializationConfig().without(Feature.FAIL_ON_UNKNOWN_PROPERTIES).withAnnotationIntrospector(pair);
            //.withDateFormat(StdDateFormat.getBlueprintISO8601Format());

        mapper.setSerializationConfig(serializationConfig);
        mapper.setDeserializationConfig(deserializationConfig);
View Full Code Here

Examples of org.codehaus.jackson.map.DeserializationConfig

    }

    ObjectMapper mapper = new ObjectMapper();
    ByteArrayInputStream bais = new ByteArrayInputStream(string.getBytes());

    DeserializationConfig deserializationConfig = mapper.getDeserializationConfig();
    deserializationConfig.set(DeserializationConfig.Feature.AUTO_DETECT_FIELDS, true);
    deserializationConfig.set(DeserializationConfig.Feature.AUTO_DETECT_SETTERS, true);
    deserializationConfig.set(DeserializationConfig.Feature.AUTO_DETECT_CREATORS, true);
    deserializationConfig.set(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, true);
    deserializationConfig.set(DeserializationConfig.Feature.CAN_OVERRIDE_ACCESS_MODIFIERS, true);
    try {
      T payload = mapper.readValue(bais, clazz);
      return payload;
    } catch (Exception e) {
      logger.error("Exception during deserialization of payload bytes: " + string, e);
View Full Code Here

Examples of org.codehaus.jackson.map.DeserializationConfig

    }

    ObjectMapper mapper = new ObjectMapper();
    ByteArrayInputStream bais = new ByteArrayInputStream(bytes);

    DeserializationConfig deserializationConfig = mapper.getDeserializationConfig();
    deserializationConfig.set(DeserializationConfig.Feature.AUTO_DETECT_FIELDS, true);
    deserializationConfig.set(DeserializationConfig.Feature.AUTO_DETECT_SETTERS, true);
    deserializationConfig.set(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, true);
    try {
      T payload = mapper.readValue(bais, clazz);
      return payload;
    } catch (Exception e) {
      logger.error("Exception during deserialization of payload bytes: " + new String(bytes), e);
View Full Code Here

Examples of org.codehaus.jackson.map.DeserializationConfig

     * First test verifies that bean builder works as expected
     */
    public void testLowLevelMaterializer() throws Exception
    {
        AbstractTypeMaterializer mat = new AbstractTypeMaterializer();
        DeserializationConfig config = new ObjectMapper().getDeserializationConfig();
        Class<?> impl = mat.materializeClass(config, Bean.class);
        assertNotNull(impl);
        assertTrue(Bean.class.isAssignableFrom(impl));
        // also, let's instantiate to make sure:
        Object ob = impl.newInstance();
View Full Code Here

Examples of org.codehaus.jackson.map.DeserializationConfig

    }

    public void testLowLevelMaterializerFailOnIncompatible() throws Exception
    {
        AbstractTypeMaterializer mat = new AbstractTypeMaterializer();
        DeserializationConfig config = new ObjectMapper().getDeserializationConfig();
        try {
            mat.materializeClass(config, InvalidBean.class);
            fail("Expected exception for incompatible property types");
        } catch (IllegalArgumentException e) {
            verifyException(e, "incompatible types");
View Full Code Here

Examples of org.codehaus.jackson.map.DeserializationConfig

    public void testLowLevelMaterializerFailOnUnrecognized() throws Exception
    {
        AbstractTypeMaterializer mat = new AbstractTypeMaterializer();
        //  by default early failure is disabled, enable:
        mat.enable(AbstractTypeMaterializer.Feature.FAIL_ON_UNMATERIALIZED_METHOD);
        DeserializationConfig config = new ObjectMapper().getDeserializationConfig();
        try {
            mat.materializeClass(config, PartialBean.class);
            fail("Expected exception for unrecognized method");
        } catch (IllegalArgumentException e) {
            verifyException(e, "Unrecognized abstract method 'foobar'");
View Full Code Here

Examples of org.codehaus.jackson.map.DeserializationConfig

public class ConversionServiceAwareObjectMapper extends ObjectMapper {
  @Autowired
  public ConversionServiceAwareObjectMapper(ConversionService conversionService) {
    AnnotationIntrospector introspector = AnnotationIntrospector.pair(new FormatAnnotationIntrospector(conversionService), DEFAULT_ANNOTATION_INTROSPECTOR);
    SerializationConfig sconfig = new SerializationConfig(DEFAULT_INTROSPECTOR, introspector, Std.defaultInstance(), null);
    DeserializationConfig dconfig = new DeserializationConfig(DEFAULT_INTROSPECTOR, introspector, Std.defaultInstance(), null);
    setSerializationConfig(sconfig);
    setDeserializationConfig(dconfig);
  }
View Full Code Here

Examples of org.codehaus.jackson.map.DeserializationConfig

      return null;
    }

    ObjectMapper mapper = new ObjectMapper();
  
    DeserializationConfig deserializationConfig = mapper.getDeserializationConfig();
    deserializationConfig.set(DeserializationConfig.Feature.AUTO_DETECT_FIELDS, true);
    deserializationConfig.set(DeserializationConfig.Feature.AUTO_DETECT_SETTERS, true);
    // deserializationConfig.set(DeserializationConfig.Feature.CAN_OVERRIDE_ACCESS_MODIFIERS, true);
    deserializationConfig.set(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, true);

    try
    {
      ClusterView view = mapper.readValue(file, ClusterView.class);
      return view;
View Full Code Here

Examples of org.codehaus.jackson.map.DeserializationConfig

  public static ClusterView deserialize(byte[] bytes)
  {
    ObjectMapper mapper = new ObjectMapper();
    ByteArrayInputStream bais = new ByteArrayInputStream(bytes);

    DeserializationConfig deserializationConfig = mapper.getDeserializationConfig();
    deserializationConfig.set(DeserializationConfig.Feature.AUTO_DETECT_FIELDS, true);
    deserializationConfig.set(DeserializationConfig.Feature.AUTO_DETECT_SETTERS, true);
    // deserializationConfig.set(DeserializationConfig.Feature.CAN_OVERRIDE_ACCESS_MODIFIERS, true);
    deserializationConfig.set(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, true);

    try
    {
      ClusterView view = mapper.readValue(bais, ClusterView.class);
      return view;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.