jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • Jackson JSON Processor
  • JACKSON-232

Allow switching of behaviour for JsonView for non-annotated fields

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: New Feature New Feature
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: 1.5
  • Component/s: None
  • Labels:
    None

Description

> Hello.
> Is there way to configure or customize ObjectMapper in such way that if
> Field or Method does not have JsonView it will not be serialized when View
> class is specified in the setSerializationView method.
> Right now (as default), even if I pass View to setSerializationView method,
> all fields and methods that don't have any view annotated with them will be
> serialized anyway. I would expect that if I specify View then only
> fields/methods annotated by that view will be serialized.
> It makes my life hard since if I have lots of objects that can embed each
> other. As solution, I need to go and create fake View (that will not be used
> anywhere) just to exclude those fields. I can't used JsonExclude since
> sometime I will Jsonize object without any view at all.

Currently, no.

It would be quite easy to add a setting to do to either:

(a) Reverse default of "visible unless otherwise stated" to "invisible
unless ..." or
(b) Allow setting of default view to use for non-annotated fields
(current settings are equivalent to having JsonView defined as
Object.class)

I assume (a) would be enough, but (b) would cover basic use case and
allow for other uses as well.

Can you fire a Jira issue for such a feature? Right now I am busy
working on polymorphic type handling for 1.5 (~60% done), but others
might be able to help with this feature on short term.
It should be very easy to add, just add a new
SerializationConfig.Feature.VIEW_INCLUDE_NON_ANNOTATED (or whatever),
add a check in BeanSerializer (or BeanPropertyWriter) for the feature.

+ Tatu +

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Tatu Saloranta added a comment - 21/Feb/10 8:30 PM

I think I just may be able to squeeze this in 1.5 release: only have one major thing to work on (ability to define root type to use, JACKSON-195), and this seems like a low-hanging fruit. So with these, and good testing for PTH, can finalize 1.5.

Show
Tatu Saloranta added a comment - 21/Feb/10 8:30 PM I think I just may be able to squeeze this in 1.5 release: only have one major thing to work on (ability to define root type to use, JACKSON-195), and this seems like a low-hanging fruit. So with these, and good testing for PTH, can finalize 1.5.
Hide
Permalink
Tatu Saloranta added a comment - 23/Feb/10 12:54 AM

Implemented, will be part of 1.5.0 release.

Show
Tatu Saloranta added a comment - 23/Feb/10 12:54 AM Implemented, will be part of 1.5.0 release.
Hide
Permalink
Tatu Saloranta added a comment - 01/Jun/10 11:30 AM

Was included in 1.5.0

Show
Tatu Saloranta added a comment - 01/Jun/10 11:30 AM Was included in 1.5.0
Hide
Permalink
Tal Gendler added a comment - 26/Dec/11 10:11 AM

Feature.DEFAULT_VIEW_INCLUSION

Show
Tal Gendler added a comment - 26/Dec/11 10:11 AM Feature.DEFAULT_VIEW_INCLUSION

People

  • Assignee:
    Tatu Saloranta
    Reporter:
    Andrei Voden
Vote (0)
Watch (0)

Dates

  • Created:
    20/Jan/10 4:35 PM
    Updated:
    26/Dec/11 10:11 AM
    Resolved:
    23/Feb/10 12:54 AM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.