File tree Expand file tree Collapse file tree 2 files changed +42
-0
lines changed
test/kotlin/com/itangcent/idea/plugin/settings/helper Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -133,6 +133,47 @@ json.field.parse.after[@com.fasterxml.jackson.annotation.JsonUnwrapped]=groovy:`
133
133
}
134
134
```
135
135
136
+ #[Jackson_JsonView]
137
+ # Support for Jackson annotation JsonView
138
+ json.cache.disable=true
139
+ api.param.parse.before=groovy:session.set("is-param",true)
140
+ api.param.parse.after=groovy:session.remove("is-param")
141
+
142
+ # Cache the JsonView information at the method level
143
+ api.method.parse.before=groovy:```
144
+ def jsonViews = it.annValue("com.fasterxml.jackson.annotation.JsonView")
145
+ //logger.info("method jsonViews:"+jsonViews)
146
+ if (jsonViews) {
147
+ session.set("json-views", jsonViews)
148
+ }
149
+ ```
150
+ api.method.parse.after=groovy:```
151
+ session.remove("json-views")
152
+ ```
153
+ # Check if a field should be ignored based on the active JsonView
154
+ field.ignore=groovy:```
155
+ if(session.get("is-param")){
156
+ return false
157
+ }
158
+ if(it.contextType()!="field"){
159
+ return false
160
+ }
161
+ def jsonViews = session.get("json-views")
162
+ //logger.info("field jsonViews:"+jsonViews)
163
+ if (jsonViews) {
164
+ def fieldViews = it.annValue("com.fasterxml.jackson.annotation.JsonView")
165
+ if (fieldViews) {
166
+ // Return true if none of the field's views are in the active JsonView
167
+ return !fieldViews.any{ fieldView-> jsonViews.any{ jsonView-> jsonView.isExtend(fieldView.name) } }
168
+ } else {
169
+ // If the field has no JsonView annotation, it should be ignored
170
+ return true
171
+ }
172
+ }
173
+ return false
174
+ ```
175
+
176
+
136
177
#[Gson]*
137
178
#Support for Gson annotations
138
179
Original file line number Diff line number Diff line change @@ -91,6 +91,7 @@ internal class RecommendConfigLoaderTest {
91
91
" Jackson_JsonPropertyOrder" ,
92
92
" Jackson_JsonIgnoreProperties" ,
93
93
" Jackson_JsonUnwrapped" ,
94
+ " Jackson_JsonView" ,
94
95
" Gson" ,
95
96
" ignore_transient_field" ,
96
97
" converts" ,
You can’t perform that action at this time.
0 commit comments