Skip to content
This repository has been archived by the owner on Nov 5, 2019. It is now read-only.

Commit

Permalink
Merge pull request #49 from jwijgerd/master
Browse files Browse the repository at this point in the history
fix for issue #48
  • Loading branch information
cowtowncoder committed Jan 7, 2015
2 parents 27e9e32 + 73a6a01 commit 9fc3cf4
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,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;
_fastName = src.getSerializedName();
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 9fc3cf4

Please sign in to comment.