Skip to content

Commit

Permalink
fix for issue FasterXML#48
Browse files Browse the repository at this point in the history
  • Loading branch information
jwijgerd committed Jan 6, 2015
1 parent e7f0e22 commit 70b18af
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ used to enhance access functionality using bytecode generation.

<properties>
<!-- annotations more stable, no patch versions -->
<jackson.annotation.version>2.4.0</jackson.annotation.version>
<jackson.annotation.version>2.4.4</jackson.annotation.version>
<jackson.core.version>2.4.4</jackson.core.version>

<!-- Generate PackageVersion.java into this directory. -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ protected OptimizedBeanPropertyWriter(BeanPropertyWriter src,
{
super(src);
this.fallbackWriter = unwrapFallbackWriter(src);
_serializer = ser; // from base class
// either use the passed on serializer or the original one
_serializer = (ser != null) ? ser : src.getSerializer();
_propertyAccessor = propertyAccessor;
_propertyIndex = propertyIndex;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.fasterxml.jackson.module.afterburner.bug48;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.module.afterburner.AfterburnerModule;
import com.fasterxml.jackson.module.afterburner.AfterburnerTestBase;

import java.math.BigDecimal;

/**
* @author Joost van de Wijgerd
*/
public class TestJsonSerializeAnnotationBug extends AfterburnerTestBase {
public void testAfterburnerModule() throws JsonProcessingException {
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.registerModule(new AfterburnerModule());

String value = objectMapper.writeValueAsString(new TestObjectWithJsonSerialize(new BigDecimal("870.04")));


}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.fasterxml.jackson.module.afterburner.bug48;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;

import java.math.BigDecimal;

/**
* @author Joost van de Wijgerd
*/
public final class TestObjectWithJsonSerialize {
@JsonSerialize(using = ToStringSerializer.class)
private final BigDecimal amount;

@JsonCreator
public TestObjectWithJsonSerialize(@JsonProperty("amount") BigDecimal amount) {
this.amount = amount;
}

@JsonSerialize(using = ToStringSerializer.class) @JsonProperty("amount")
public BigDecimal getAmount() {
return amount;
}
}

0 comments on commit 70b18af

Please sign in to comment.