Menu

Tree [4250ea] master /
 History

HTTPS access


File Date Author Commit
 .circleci 2018-11-06 rkonovalov rkonovalov [5e05d6] Changed Circle CI config
 .idea 2018-11-10 rkonovalov rkonovalov [63a14b] Refactored tests
 src 2018-11-11 rkonovalov rkonovalov [9e8d0f] Removed unused field
 .travis.yml 2018-11-08 rkonovalov rkonovalov [6a533c] Changed Travis CI config
 LICENSE 2018-10-14 rkonovalov rkonovalov [7a0e1c] Added license
 README.md 2018-11-14 rkonovalov rkonovalov [4250ea] Removed Google Analytics
 codecov.yml 2018-11-10 rkonovalov rkonovalov [8349fa] Changed codecov
 jsonignore.iml 2018-10-13 rkonovalov rkonovalov [e65a09] Deployment of 1.0.0 version to Maven central
 pom.xml 2018-11-11 rkonovalov rkonovalov [c12f50] Version changed from 1.0.7 to 1.0.8
 sonar-project.properties 2018-11-11 rkonovalov rkonovalov [d214f0] Refactored properties

Read Me

License
Build Status
Maven Central
Javadocs
codecov
Codacy Badge
SonarCloud

About

This module could be used in Spring Web Service project for filter(exclude) of fields in Service response.
When you used Jackson @JsonView interface and need more powerful and flexibility, this module could be useful.
For information please follow the links below.

Index

Diagram of module flowchart

Diagram

Installation

For using this module you need to import dependency

<dependency>
    <groupId>com.github.rkonovalov</groupId>
    <artifactId>json-ignore</artifactId>
    <version>1.0.8</version>
</dependency>

Getting started

For activation of JFilter module just add next annotations

  • Component scan and enable filter
@ComponentScan({"com.jfilter.components"})
@EnableJsonFilter

Example o usage

This example illustrates how easy you can configure Service Response.
Just add FieldFilterSetting annotation with filterable fields and module will exclude them from response

    @FieldFilterSetting(className = User.class, fields = {"id", "password", "secretKey"})

    @RequestMapping(value = "/users/signIn",
            params = {"email", "password"}, method = RequestMethod.POST,
            consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE},
            produces = {MediaType.APPLICATION_JSON_VALUE})            
    public User signIn(@RequestParam("email") String email, @RequestParam("password") String password) {
        return userController.signInUser(email, password);
    }
  • Service response before filtration
{
  "id": 10,
  "email": "janedoe@gmail.com", 
  "fullName": "Jane Doe",
  "password": "12345",
  "secretKey": "54321",
  "address": {
    "id": 15,
    "apartmentNumber": 22,
    "street": {
      "id": 155,
      "streetName": "Bourbon Street",
      "streetNumber": 15
    }
  }
}
  • Service response after filtration
{ 
  "email": "janedoe@gmail.com", 
  "fullName": "Jane Doe",
  "address": {
    "id": 15,
    "apartmentNumber": 22,
    "street": {
      "id": 155,
      "streetName": "Bourbon Street",
      "streetNumber": 15
    }
  }
}

For more examples please follow to the link Examples

Release notes

Version 1.0.8

* Added Dynamic Filter which allows to create own filters with custom behaviour
* Added DynamicSessionFilter for storing custom field filter in session
* Added feature for auto loading XML Schema-based configuration filter when it changed on runtime
* Changed package name from com.json.ignore to com.jfilter 
* Changed package from advice to components
* Fixed bug in FileFilter which not allowed to load xml configuration from external source

Version 1.0.7

* Added FileWatcher controller which auto reloads modified XML Schema based configurations
* Refactored Javadoc
* Fixed incorrect Jackson XML dependency importing

Version 1.0.6

* Added JSON/XML converters inherited from HttpMessageConverter
* Removed native reflection and added Jackson BeanSerializerModifier for field filtering
* Added EnableJsonFilter annotation for enabling/disabling filtration
* Added ability to apply filter annotations on whole Spring Rest controller
* Fixed bugs

Version 1.0.5

* Added Filter provider for improving execution speed
* Fixed bugs

Version 1.0.4

* Added xml Schema-based configuration
* Fixed bugs

Version 1.0.3

* Added session strategy filtering

Version 1.0.2

* Added additional constructors

Version 1.0.0

* Initial release
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.