[ 
https://issues.apache.org/jira/browse/JOHNZON-152?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16306207#comment-16306207
 ] 

Steven Walters commented on JOHNZON-152:
----------------------------------------

Romain,

I don't seem to understand what you're indicating with the {type:xxxx, 
value:{...}} reference. 
For us there's about 3 or 4 custom types that all do this, it's simpler to have 
a single ObjectConverter.Writer that generically converts the object into a map 
and then passes that along the MappingGenerator. Before we had individual 
converters for each of the types but this become more nuisance than having a 
single generic one.

Reinhard,
Right now we're only using the types in question for serialization purposes 
(they are not deserialized), as they're types for error responses from the web 
application. So for now we only use ObjectConverter.Writer alone.

> Ability to serialize field of a type from value introspection instead of 
> field introspection
> --------------------------------------------------------------------------------------------
>
>                 Key: JOHNZON-152
>                 URL: https://issues.apache.org/jira/browse/JOHNZON-152
>             Project: Johnzon
>          Issue Type: Wish
>          Components: Mapper
>    Affects Versions: 1.1.5
>            Reporter: Steven Walters
>            Priority: Minor
>
> In our project, we have a few types that have an Object field that is used to 
> accept a few different types of objects.
> * Sometimes the field is an effective primitives (Float, Integer, Long, etc)
> * Sometimes they're Collections (List, Set) 
> * Sometimes they're other custom defined objects
> Right now johnzon mapper determines the type of the field based on its 
> defined type "Object" which means just about nothing. This almost always 
> causes serialization issues (with default behavior) unless its null.
> We would like to have an annotation (such as @JohnzonDynamic) to indicate the 
> field is dynamic and its type should be determined via introspection of the 
> value, rather than the field's declared type. Similar to how a map's value is 
> done.
> For simplicity, this could be considered a read-only field to avoid the 
> complexity of trying to set this field to whatever data comes in during 
> deserialization.
> Right now we're working around this via a custom ObjectWriter that converts 
> the object to a map and then passes the map to serialization, which has some 
> inconveniences of maintenance.
> Maybe other projects could see some use of this?



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to