diff --git a/src/main/java/com/fasterxml/jackson/databind/DeserializationFeature.java b/src/main/java/com/fasterxml/jackson/databind/DeserializationFeature.java
index 595df82fa5..908073483c 100644
--- a/src/main/java/com/fasterxml/jackson/databind/DeserializationFeature.java
+++ b/src/main/java/com/fasterxml/jackson/databind/DeserializationFeature.java
@@ -430,6 +430,19 @@ public enum DeserializationFeature implements ConfigFeature
*/
READ_ENUMS_USING_TO_STRING(false),
+ /**
+ * Feature that determines standard deserialization mechanism used for
+ * QName values: if enabled, QNames are assumed to have been serialized using
+ * return value of QName.toString()
;
+ * if disabled, it is assumed that the QName was serialized as an object.
+ *
+ * Note: this feature should usually have same value + * as {@link SerializationFeature#WRITE_QNAMES_USING_TO_STRING}. + *
+ * Feature is disabled by default.
+ */
+ READ_QNAMES_USING_VALUE_OF(true),
+
/**
* Feature that allows unknown Enum values to be parsed as {@code null} values.
* If disabled, unknown Enum values will throw exceptions.
diff --git a/src/main/java/com/fasterxml/jackson/databind/SerializationFeature.java b/src/main/java/com/fasterxml/jackson/databind/SerializationFeature.java
index a16e5cbeff..013893a8ba 100644
--- a/src/main/java/com/fasterxml/jackson/databind/SerializationFeature.java
+++ b/src/main/java/com/fasterxml/jackson/databind/SerializationFeature.java
@@ -292,6 +292,18 @@ public enum SerializationFeature implements ConfigFeature
*/
WRITE_ENUMS_USING_TO_STRING(false),
+ /**
+ * Feature that determines standard serialization mechanism used for
+ * QName values: if enabled, return value of QName.toString()
+ * is used; if disabled, the QName is serialized as an object.
+ *
+ * Note: this feature should usually have same value + * as {@link DeserializationFeature#READ_QNAMES_USING_VALUE_OF}. + *
+ * Feature is disabled by default.
+ */
+ WRITE_QNAMES_USING_TO_STRING(true),
+
/**
* Feature that determines whether Java Enum values are serialized
* as numbers (true), or textual values (false). If textual values are
diff --git a/src/main/java/com/fasterxml/jackson/databind/ext/CoreXMLDeserializers.java b/src/main/java/com/fasterxml/jackson/databind/ext/CoreXMLDeserializers.java
index 76609a3914..d42d7504c2 100644
--- a/src/main/java/com/fasterxml/jackson/databind/ext/CoreXMLDeserializers.java
+++ b/src/main/java/com/fasterxml/jackson/databind/ext/CoreXMLDeserializers.java
@@ -7,6 +7,8 @@
import javax.xml.namespace.QName;
import com.fasterxml.jackson.core.*;
+import com.fasterxml.jackson.core.type.TypeReference;
+
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.deser.Deserializers;
import com.fasterxml.jackson.databind.deser.std.FromStringDeserializer;
@@ -40,7 +42,10 @@ public JsonDeserializer> findBeanDeserializer(JavaType type,
{
Class> raw = type.getRawClass();
if (raw == QName.class) {
- return new Std(raw, TYPE_QNAME);
+ if (config == null || config.isEnabled(DeserializationFeature.READ_QNAMES_USING_VALUE_OF)) {
+ return new Std(raw, TYPE_QNAME);
+ }
+ return new QNameObjectDeserializer();
}
if (raw == XMLGregorianCalendar.class) {
return new Std(raw, TYPE_G_CALENDAR);
@@ -149,4 +154,27 @@ protected XMLGregorianCalendar _gregorianFromDate(DeserializationContext ctxt,
return _dataTypeFactory.newXMLGregorianCalendar(calendar);
}
}
+
+ private class QNameObjectDeserializer extends JsonDeserializer