Skip to content

Commit 3da7731

Browse files
authored
Create README.md
1 parent d4c4599 commit 3da7731

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Filtering API
2+
3+
This API demonstrates how to perform filtering on JSON responses in Spring Boot using both static and dynamic serialization.
4+
5+
## Static Filtering
6+
7+
Static filtering involves excluding certain fields from the JSON response at either the class level or the field level. This means that these fields will always be excluded from the JSON serialization, regardless of the context.
8+
9+
### Class-level Static Filtering
10+
11+
At the class level, static filtering can be applied using Jackson's `@JsonIgnoreProperties` annotation. This annotation allows you to specify fields to be ignored during serialization for all instances of the class.
12+
13+
### Field-level Static Filtering
14+
15+
At the field level, static filtering can be applied using Jackson's `@JsonIgnore` annotation. This annotation allows you to specify individual fields to be ignored during serialization.
16+
17+
### Note:
18+
Make sure to uncomment the `@JsonIgnoreProperties` or `@JsonIgnore` annotations as needed in the `Student` class to apply the desired static filtering behavior.
19+
20+
## Dynamic Filtering
21+
22+
Dynamic filtering involves excluding certain fields from the JSON response based on runtime conditions. This allows for more flexibility as filtering can be applied selectively based on the request or other factors.
23+
24+
## Endpoints
25+
26+
### `/filtering`
27+
28+
- GET request to this endpoint returns a single `Student` object with filtering applied.
29+
- Filtering is applied to include only the "name" and "city" fields in the response.
30+
31+
### `/filtering-list`
32+
33+
- GET request to this endpoint returns a list of `Student` objects with filtering applied.
34+
- Filtering is applied to include only the "name" and "mobile" fields in the response.
35+
36+
This README provides detailed explanations of both static and dynamic filtering mechanisms in the API and how to use the provided endpoints. Adjust the content as needed for your specific project documentation.

0 commit comments

Comments
 (0)