File tree 3 files changed +34
-24
lines changed
jakarta-jsonp/src/test/java/com/fasterxml/jackson/datatype/jsonp
jsr-353/src/test/java/com/fasterxml/jackson/datatype/jsr353
3 files changed +34
-24
lines changed Original file line number Diff line number Diff line change 10
10
11
11
public class JsonValueDeserializationTest extends TestBase
12
12
{
13
+ static class ObjectImpl {
14
+ JsonValue obj1 ;
15
+ JsonValue obj2 ;
16
+
17
+ @ ConstructorProperties ({"obj1" , "obj2" })
18
+ public ObjectImpl (JsonValue obj1 , JsonValue obj2 ) {
19
+ this .obj1 = obj1 ;
20
+ this .obj2 = obj2 ;
21
+ }
22
+ }
23
+
13
24
private final ObjectMapper MAPPER = newMapper ();
14
25
15
26
public void testSimpleArray () throws Exception
@@ -115,20 +126,12 @@ public void testNullNode() throws Exception
115
126
// for [datatype-jsr353#19]
116
127
public void testConstructorProperties () throws Exception
117
128
{
118
- final String JSON = "{\" obj1\" :{}}" ;
119
- ObjectImpl ob = MAPPER .readValue (JSON , ObjectImpl .class );
129
+ ObjectImpl ob = MAPPER .readValue ("{\" obj1\" :{}}" , ObjectImpl .class );
120
130
assertTrue (ob .obj1 instanceof JsonObject );
121
131
assertNull (ob .obj2 );
122
- }
123
-
124
- static class ObjectImpl {
125
- JsonValue obj1 ;
126
- JsonValue obj2 ;
127
132
128
- @ ConstructorProperties ({"obj1" , "obj2" })
129
- public ObjectImpl (JsonValue obj1 , JsonValue obj2 ) {
130
- this .obj1 = obj1 ;
131
- this .obj2 = obj2 ;
132
- }
133
+ ObjectImpl ob2 = MAPPER .readValue ("{\" obj2\" :null}" , ObjectImpl .class );
134
+ assertNull (ob2 .obj1 );
135
+ assertSame (JsonValue .NULL , ob2 .obj2 );
133
136
}
134
137
}
Original file line number Diff line number Diff line change 10
10
11
11
public class JsonValueDeserializationTest extends TestBase
12
12
{
13
+ // for [datatype-jsr353#19]
14
+ static class ObjectImpl {
15
+ JsonValue obj1 ;
16
+ JsonValue obj2 ;
17
+
18
+ @ ConstructorProperties ({"obj1" , "obj2" })
19
+ public ObjectImpl (JsonValue obj1 , JsonValue obj2 ) {
20
+ this .obj1 = obj1 ;
21
+ this .obj2 = obj2 ;
22
+ }
23
+ }
24
+
13
25
private final ObjectMapper MAPPER = newMapper ();
14
26
15
27
public void testSimpleArray () throws Exception
@@ -115,20 +127,12 @@ public void testNullNode() throws Exception
115
127
// for [datatype-jsr353#19]
116
128
public void testConstructorProperties () throws Exception
117
129
{
118
- final String JSON = "{\" obj1\" :{}}" ;
119
- ObjectImpl ob = MAPPER .readValue (JSON , ObjectImpl .class );
130
+ ObjectImpl ob = MAPPER .readValue ("{\" obj1\" :{}}" , ObjectImpl .class );
120
131
assertTrue (ob .obj1 instanceof JsonObject );
121
132
assertNull (ob .obj2 );
122
- }
123
-
124
- static class ObjectImpl {
125
- JsonValue obj1 ;
126
- JsonValue obj2 ;
127
133
128
- @ ConstructorProperties ({"obj1" , "obj2" })
129
- public ObjectImpl (JsonValue obj1 , JsonValue obj2 ) {
130
- this .obj1 = obj1 ;
131
- this .obj2 = obj2 ;
132
- }
134
+ ObjectImpl ob2 = MAPPER .readValue ("{\" obj2\" :null}" , ObjectImpl .class );
135
+ assertNull (ob2 .obj1 );
136
+ assertSame (JsonValue .NULL , ob2 .obj2 );
133
137
}
134
138
}
Original file line number Diff line number Diff line change @@ -14,6 +14,9 @@ Modules:
14
14
15
15
#17 : Add configurable amount representations for Joda Money module
16
16
(contributed by Andrzej P)
17
+ #19 : `JsonValue.NULL ` deserialization has different behaviours with constructor properties
18
+ vs public properties
19
+ (contributed by xdrsynapse@github)
17
20
18
21
2.13.2 (06 -Mar-2022 )
19
22
2.13.1 (19 -Dec-2021 )
You can’t perform that action at this time.
0 commit comments