Jackson JSON Processor
  1. Jackson JSON Processor
  2. JACKSON-650

Allow "missing filter id" to mean "do not filter"

    Details

    • Type: New Feature New Feature
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Number of attachments :
      0

      Description

      I'm using JSON filter in my project. But I found one discomfort while working with it.

      In my project I have universal mechanism of serialization objects to JSON. In this mechanism I try dinamically detect, if object has filters. If it has, then I use filter mechanism.

      For example, I have Mail bean in my project. And this Mail bean refers to Player bean:

      Mail

      { Player fromPlayer; }

      In my Player bean I have some fields, which I don't need to serialize, when serialize Mail(but in other cases I need it all). That's why I use JSON Filter: I add JsonFilter("playerFilter") annotaion to Player class. And after, when I serialize Mail object, I add fields to "playerFilter". That's ok.

      But, for example, I have reference to player from other bean. But this time, I don't need in filtering fields of Player object(but need filtering fields of other objects). And when I try to serialize object, I must to add anything to playerFilter, or (else) I get exception:"org.codehaus.jackson.map.JsonMappingException - No filter configured with id 'playerFilter'". So, I need always configure filter, even I don't need it. I think, it would be more handy: if i don't configure filter - serialize all default fields.

        Activity

        Hide
        Tatu Saloranta added a comment -

        Hmmh. Ok, yes, this actually makes sense.

        Show
        Tatu Saloranta added a comment - Hmmh. Ok, yes, this actually makes sense.
        Hide
        Tatu Saloranta added a comment -

        Ok: one thing to note is that SimpleFilterProvider already allows specifying "default filter", used if no filter matches id. This could already be used to add 'dont filter anything' filter.

        But I will add another convenience feature: SimpleFilterProvider.setFailOnUnknownId(false), calling which means that if no matching filter is find, no filtering will be performed.
        So this should further simplify specifying such behavior. I will leave current behavior is the default for backwards compatibility.

        Show
        Tatu Saloranta added a comment - Ok: one thing to note is that SimpleFilterProvider already allows specifying "default filter", used if no filter matches id. This could already be used to add 'dont filter anything' filter. But I will add another convenience feature: SimpleFilterProvider.setFailOnUnknownId(false), calling which means that if no matching filter is find, no filtering will be performed. So this should further simplify specifying such behavior. I will leave current behavior is the default for backwards compatibility.
        Hide
        Tatu Saloranta added a comment -

        Implemented.

        Show
        Tatu Saloranta added a comment - Implemented.

          People

          • Assignee:
            Tatu Saloranta
            Reporter:
            Kirill Sukhanov
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: