File tree Expand file tree Collapse file tree 2 files changed +79
-0
lines changed
src/test/java/com/alibaba/json/bvt Expand file tree Collapse file tree 2 files changed +79
-0
lines changed Original file line number Diff line number Diff line change
1
+ package com .alibaba .json .bvt ;
2
+
3
+ import junit .framework .Assert ;
4
+ import junit .framework .TestCase ;
5
+
6
+ import com .alibaba .fastjson .JSON ;
7
+ import com .alibaba .fastjson .annotation .JSONField ;
8
+
9
+ public class AnnotationTest3 extends TestCase {
10
+
11
+ public void test_supperField () throws Exception {
12
+ C c = new C ();
13
+ c .setId (123 );
14
+ c .setName ("jobs" );
15
+
16
+ String str = JSON .toJSONString (c );
17
+ Assert .assertEquals ("{\" ID\" :123,\" name\" :\" jobs\" }" , str );
18
+ }
19
+
20
+ public static class S {
21
+
22
+ @ JSONField (name = "ID" )
23
+ private int id ;
24
+
25
+ public int getId () {
26
+ return id ;
27
+ }
28
+
29
+ public void setId (int id ) {
30
+ this .id = id ;
31
+ }
32
+
33
+ }
34
+
35
+ public static class C extends S {
36
+
37
+ private String name ;
38
+
39
+ public String getName () {
40
+ return name ;
41
+ }
42
+
43
+ public void setName (String name ) {
44
+ this .name = name ;
45
+ }
46
+
47
+ }
48
+ }
Original file line number Diff line number Diff line change
1
+ package com .alibaba .json .bvt .bug ;
2
+
3
+ import junit .framework .TestCase ;
4
+
5
+ import com .alibaba .fastjson .JSON ;
6
+ import com .alibaba .fastjson .serializer .SerializerFeature ;
7
+
8
+ public class Bug_for_qqdwll2012 extends TestCase {
9
+
10
+ public void test_for_x () throws Exception {
11
+ VO vo = new VO ();
12
+ vo .setValue ("<a href=\" http://www.baidu.com\" > 问题链接 </a> |" );
13
+
14
+ String text = JSON .toJSONString (vo , SerializerFeature .WriteSlashAsSpecial );
15
+ System .out .println (text );
16
+ }
17
+
18
+ public static class VO {
19
+
20
+ private String value ;
21
+
22
+ public String getValue () {
23
+ return value ;
24
+ }
25
+
26
+ public void setValue (String value ) {
27
+ this .value = value ;
28
+ }
29
+
30
+ }
31
+ }
You can’t perform that action at this time.
0 commit comments