@@ -62,6 +62,7 @@ public AbstractObjectParser<T, M, L> setParser(Parser<T, M, L> parser) {
6262 */
6363 protected final boolean drop ;
6464 private List <String > stringKeyList ;
65+ private List <String > trimKeyList ;
6566
6667 /**for single object
6768 */
@@ -109,6 +110,11 @@ public AbstractObjectParser(@NotNull M request, String parentPath, SQLConfig<T,
109110 String [] sks = StringUtil .split (str );
110111 stringKeyList = sks == null || sks .length <= 0 ? null : Arrays .asList (sks );
111112 request .remove (KEY_STRING );
113+
114+ String trim = getString (request , KEY_TRIM );
115+ String [] trims = StringUtil .split (trim );
116+ trimKeyList = trims == null || trims .length <= 0 ? null : Arrays .asList (trims );
117+ request .remove (KEY_TRIM );
112118 }
113119 }
114120
@@ -286,13 +292,16 @@ public AbstractObjectParser<T, M, L> parse(String name, boolean isReuse) throws
286292 // hasOtherKeyNotFun = true;
287293 // }
288294
289- if (stringKeyList != null && stringKeyList .contains (key )) {
290- // 统一格式 String val = value == null || value instanceof String ? (String) value : JSON.toJSONString(value);
291- if (onParse (key , JSON .toJSONString (value )) == false ) {
292- invalidate ();
293- }
295+ boolean isTrim = (trimKeyList != null && trimKeyList .contains (key ));
296+ boolean toStr = isTrim || (stringKeyList != null && stringKeyList .contains (key ));
297+ if (toStr ) {
298+ value = JSON .toJSONString (value );
294299 }
295- else if (startsWithAt || key .endsWith ("@" ) || (key .endsWith ("<>" ) && value instanceof Map <?, ?>)) {
300+ if (isTrim && value != null ) {
301+ value = StringUtil .trim (value );
302+ }
303+
304+ if (startsWithAt || key .endsWith ("@" ) || (key .endsWith ("<>" ) && value instanceof Map <?, ?>)) {
296305 if (onParse (key , value ) == false ) {
297306 invalidate ();
298307 }
@@ -1242,6 +1251,9 @@ public void recycle() {
12421251 if (stringKeyList != null ) { // 避免被全局关键词覆盖 && ! stringKeyList.isEmpty()) {
12431252 request .put (KEY_STRING , StringUtil .get (stringKeyList .toArray ()));
12441253 }
1254+ if (trimKeyList != null ) { // 避免被全局关键词覆盖 && ! trimKeyList.isEmpty()) {
1255+ request .put (KEY_TRIM , StringUtil .get (trimKeyList .toArray ()));
1256+ }
12451257
12461258 method = null ;
12471259 parentPath = null ;
0 commit comments