File tree Expand file tree Collapse file tree 4 files changed +70
-0
lines changed Expand file tree Collapse file tree 4 files changed +70
-0
lines changed Original file line number Diff line number Diff line change 5757 <artifactId >commons-beanutils</artifactId >
5858 <version >1.8.3</version >
5959 </dependency >
60+ <dependency >
61+ <groupId >com.alibaba</groupId >
62+ <artifactId >fastjson</artifactId >
63+ <version >1.2.5</version >
64+ </dependency >
6065
6166 <dependency >
6267 <groupId >commons-collections</groupId >
Original file line number Diff line number Diff line change 1+ package com .object ;
2+
3+ import net .sf .json .JSONObject ;
4+
5+ /**
6+ * @Auther: Administrator
7+ * @Date: 2019\7\5 0005 0:45
8+ * @Description:
9+ */
10+ public class CloneTest {
11+ public static void main (String [] args ) {
12+ JSONObject paramJson = new JSONObject ();
13+ paramJson .put ("age" ,26 );
14+ paramJson .put ("name" ,"lin" );
15+ JSONObject cloneJson = paramJson ;
16+ cloneJson .put ("age" ,27 );
17+ System .out .println ("paramJson:" +paramJson .toString ());
18+ System .out .println ("cloneJson:" +cloneJson .toString ());
19+ }
20+ }
Original file line number Diff line number Diff line change 1+ package com .object ;
2+
3+ import com .alibaba .fastjson .JSONObject ;
4+ import org .apache .commons .lang .SerializationUtils ;
5+
6+ /**
7+ * @Auther: Administrator
8+ * @Date: 2019\7\5 0005 0:59
9+ * @Description:
10+ */
11+ public class DeepCloneTest {
12+ public static void main (String [] args ) {
13+ JSONObject paramJson = new JSONObject ();
14+ paramJson .put ("age" ,26 );
15+ paramJson .put ("name" ,"lin" );
16+ JSONObject cloneJson = (JSONObject )SerializationUtils .clone (paramJson );
17+ cloneJson .put ("age" ,27 );
18+ System .out .println ("paramJson:" +paramJson .toString ());
19+ System .out .println ("cloneJson:" +cloneJson .toString ());
20+ }
21+ }
Original file line number Diff line number Diff line change 1+ package com .object ;
2+
3+ import net .sf .json .JSONObject ;
4+ import org .apache .commons .beanutils .BeanUtils ;
5+
6+ import java .lang .reflect .InvocationTargetException ;
7+
8+ /**
9+ * @Auther: Administrator
10+ * @Date: 2019\7\5 0005 0:57
11+ * @Description:
12+ */
13+ public class DeepCloneTest2 {
14+ public static void main (String [] args ) throws InvocationTargetException , IllegalAccessException {
15+ JSONObject paramJson = new JSONObject ();
16+ paramJson .put ("age" ,26 );
17+ paramJson .put ("name" ,"lin" );
18+ JSONObject cloneJson = new JSONObject ();
19+ BeanUtils .copyProperties (cloneJson ,paramJson );
20+ cloneJson .put ("test" ,27 );
21+ System .out .println ("paramJson:" +paramJson .toString ());
22+ System .out .println ("cloneJson:" +cloneJson .toString ());
23+ }
24+ }
You can’t perform that action at this time.
0 commit comments