File tree Expand file tree Collapse file tree 1 file changed +53
-0
lines changed
snack4-test/src/test/java/features/snack4/codec Expand file tree Collapse file tree 1 file changed +53
-0
lines changed Original file line number Diff line number Diff line change 1+ package features .snack4 .codec ;
2+
3+ import org .junit .jupiter .api .Assertions ;
4+ import org .junit .jupiter .api .Test ;
5+ import org .noear .snack4 .ONode ;
6+
7+ import java .util .HashMap ;
8+ import java .util .Map ;
9+
10+ /**
11+ *
12+ * @author noear 2025/12/28 created
13+ *
14+ */
15+ public class LoopNestingTest {
16+ @ Test
17+ public void case1 () {
18+ Map <String , Object > tmp = new HashMap <>();
19+ tmp .put ("a" , "a" );
20+ tmp .put ("b" , tmp );
21+
22+ String json = ONode .serialize (tmp );
23+ System .out .println (json );
24+ Assertions .assertEquals ("{\" a\" :\" a\" }" , json );
25+ }
26+
27+ @ Test
28+ public void case2 () {
29+ A tmp = new A ();
30+ tmp .a = "a" ;
31+ tmp .b = tmp ;
32+
33+ String json = ONode .serialize (tmp );
34+ System .out .println (json );
35+ Assertions .assertEquals ("{\" a\" :\" a\" }" , json );
36+ }
37+
38+ @ Test
39+ public void case2_ref () {
40+ A tmp = new A ();
41+ tmp .a = "a" ;
42+ tmp .b = tmp ;
43+
44+ A a = ONode .deserialize ("{\" a\" :\" a\" }" , A .class );
45+ Assertions .assertEquals ("a" , "a" );
46+ assert a .b == a ;
47+ }
48+
49+ public static class A {
50+ public String a ;
51+ public A b ;
52+ }
53+ }
You can’t perform that action at this time.
0 commit comments