From e807494ce847c86f5116de1c7385af116c49cbb3 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Tue, 10 Dec 2013 20:10:58 -0800 Subject: [PATCH] Fix #38 (requires jackson-databind 2.3.1) --- pom.xml | 2 +- release-notes/VERSION | 3 ++ .../afterburner/ser/SerializerModifier.java | 8 ++--- .../afterburner/ser/TestJsonFilter.java | 2 +- .../module/afterburner/ser/TestRawValues.java | 31 +++++++++++++++++++ 5 files changed, 38 insertions(+), 8 deletions(-) create mode 100644 src/test/java/com/fasterxml/jackson/module/afterburner/ser/TestRawValues.java diff --git a/pom.xml b/pom.xml index 0fe8304..e6e75ca 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ used to enhance access functionality using bytecode generation. 2.3.0 - 2.3.0 + 2.3.1-SNAPSHOT com/fasterxml/jackson/module/afterburner diff --git a/release-notes/VERSION b/release-notes/VERSION index 1e8f359..b9ab87c 100644 --- a/release-notes/VERSION +++ b/release-notes/VERSION @@ -1,6 +1,9 @@ Project: jackson-module-afterburner Version: 2.3.1 (xx-Dec-2013) +#38: Handling of @JsonRawValue broken (require 2.3.1 of jackson-databind for fix) + (reported by willcheck@github) + ------------------------------------------------------------------------ === History: === ------------------------------------------------------------------------ diff --git a/src/main/java/com/fasterxml/jackson/module/afterburner/ser/SerializerModifier.java b/src/main/java/com/fasterxml/jackson/module/afterburner/ser/SerializerModifier.java index 8c50841..b5c6aed 100644 --- a/src/main/java/com/fasterxml/jackson/module/afterburner/ser/SerializerModifier.java +++ b/src/main/java/com/fasterxml/jackson/module/afterburner/ser/SerializerModifier.java @@ -87,12 +87,8 @@ protected PropertyAccessorCollector findProperties(Class beanClass, continue; } } - /* [Issue#9]: also skip unwrapping stuff... - * - * TODO: 24-Jul-2013, tatu: should use "BeanPropertyWriter.isUnwrapping()" when - * Jackson 2.3 is out (and adds it) - */ - if (bpw instanceof UnwrappingBeanPropertyWriter) { + // [Issue#9]: also skip unwrapping stuff... + if (bpw.isUnwrapping()) { continue; } diff --git a/src/test/java/com/fasterxml/jackson/module/afterburner/ser/TestJsonFilter.java b/src/test/java/com/fasterxml/jackson/module/afterburner/ser/TestJsonFilter.java index 17f886b..a496a53 100644 --- a/src/test/java/com/fasterxml/jackson/module/afterburner/ser/TestJsonFilter.java +++ b/src/test/java/com/fasterxml/jackson/module/afterburner/ser/TestJsonFilter.java @@ -59,7 +59,7 @@ static class FilteredProps @JsonFilter("b") public Bean second = new Bean(); } - + /* /********************************************************** /* Unit tests diff --git a/src/test/java/com/fasterxml/jackson/module/afterburner/ser/TestRawValues.java b/src/test/java/com/fasterxml/jackson/module/afterburner/ser/TestRawValues.java new file mode 100644 index 0000000..e04c2fa --- /dev/null +++ b/src/test/java/com/fasterxml/jackson/module/afterburner/ser/TestRawValues.java @@ -0,0 +1,31 @@ +package com.fasterxml.jackson.module.afterburner.ser; + +import com.fasterxml.jackson.annotation.JsonRawValue; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.module.afterburner.AfterburnerTestBase; + +public class TestRawValues extends AfterburnerTestBase +{ + static class SerializableObject + { + public SerializableObject(String v) { value = v; } + + @JsonRawValue + public String value; + } + + /* + /********************************************************** + /* Unit tests + /********************************************************** + */ + + private final ObjectMapper MAPPER = mapperWithModule(); + + public void testAfterBurner() throws Exception + { + SerializableObject so = new SerializableObject("[123]"); + + assertEquals("{\"value\":[123]}", MAPPER.writeValueAsString(so)); + } +}