File tree Expand file tree Collapse file tree
src/main/java/apijson/fastjson2 Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -87,16 +87,19 @@ public Object put(String key, Object value) {
8787 }
8888
8989 Object target = null ;
90- try {
91- target = JSON .parse (value );
92- } catch (Exception e ) {
93- // nothing
94- e .printStackTrace ();
95- }
90+ Class <?> cls = value .getClass ();
91+ if ( ! (value instanceof Map <?, ?> || value instanceof Collection <?> || JSON .isBoolOrNumOrStr (value ))) {
92+ try {
93+ target = JSON .parse (value );
94+ } catch (Exception e ) {
95+ // nothing
96+ e .printStackTrace ();
97+ }
98+ }
9699 // if (target == null) { // "tag":"User" 报错
97100 // return null;
98101 // }
99- return super .put (StringUtil .isNotEmpty (key , true ) ? key : value . getClass () .getSimpleName () //must handle key here
102+ return super .put (StringUtil .isNotEmpty (key , true ) ? key : cls .getSimpleName () //must handle key here
100103 , target == null ? value : target );
101104 }
102105
You can’t perform that action at this time.
0 commit comments