You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When declaring a TypeConverter, it properly runs if the Java field is of type String but if it is of type Object in which case XStream puts the runtime type in a class attribute, the TypeConverter never runs.
The problem is in the MappedXMLStreamWriter.JSONPropertyObject class in the withProperty method as well as in MappedXMLStreamWriter.JSONPropertyString.
Current implementation:
Object value = property.getValue();
if (add && value instanceof String) {
value = this.convention.convertToJSONPrimitive((String)value);
}
Suggested implementation idea (needs exception handling etc):
Object value = property.getValue();
if (add && value instanceof String) {
value = this.convention.convertToJSONPrimitive((String)value);
} else if (add && value instanceof JSONObject && "string".equals(value.get("@class"))) {
value.put("$", this.convention.convertToJSONPrimitive((String)value.get("$")));
}
The text was updated successfully, but these errors were encountered:
When declaring a TypeConverter, it properly runs if the Java field is of type String but if it is of type Object in which case XStream puts the runtime type in a
class
attribute, the TypeConverter never runs.The problem is in the
MappedXMLStreamWriter.JSONPropertyObject
class in thewithProperty
method as well as inMappedXMLStreamWriter.JSONPropertyString
.Current implementation:
Suggested implementation idea (needs exception handling etc):
The text was updated successfully, but these errors were encountered: