File tree 2 files changed +44
-0
lines changed
jakarta-jsonp/src/test/java/com/fasterxml/jackson/datatype/jsonp
jsr-353/src/test/java/com/fasterxml/jackson/datatype/jsr353
2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change 6
6
import com .fasterxml .jackson .databind .ObjectMapper ;
7
7
import com .fasterxml .jackson .databind .node .ObjectNode ;
8
8
9
+ import java .beans .ConstructorProperties ;
10
+
9
11
public class JsonValueDeserializationTest extends TestBase
10
12
{
11
13
private final ObjectMapper MAPPER = newMapper ();
@@ -109,4 +111,24 @@ public void testNullNode() throws Exception
109
111
final JsonValue deserializedNull = MAPPER .readValue (serializedNull , JsonValue .class );
110
112
assertEquals (JsonValue .NULL , deserializedNull );
111
113
}
114
+
115
+ // for [datatype-jsr353#19]
116
+ public void testConstructorProperties () throws Exception
117
+ {
118
+ final String JSON = "{\" obj1\" :{}}" ;
119
+ ObjectImpl ob = MAPPER .readValue (JSON , ObjectImpl .class );
120
+ assertTrue (ob .obj1 instanceof JsonObject );
121
+ assertNull (ob .obj2 );
122
+ }
123
+
124
+ static class ObjectImpl {
125
+ JsonValue obj1 ;
126
+ JsonValue obj2 ;
127
+
128
+ @ ConstructorProperties ({"obj1" , "obj2" })
129
+ public ObjectImpl (JsonValue obj1 , JsonValue obj2 ) {
130
+ this .obj1 = obj1 ;
131
+ this .obj2 = obj2 ;
132
+ }
133
+ }
112
134
}
Original file line number Diff line number Diff line change 6
6
import com .fasterxml .jackson .databind .ObjectMapper ;
7
7
import com .fasterxml .jackson .databind .node .ObjectNode ;
8
8
9
+ import java .beans .ConstructorProperties ;
10
+
9
11
public class JsonValueDeserializationTest extends TestBase
10
12
{
11
13
private final ObjectMapper MAPPER = newMapper ();
@@ -109,4 +111,24 @@ public void testNullNode() throws Exception
109
111
final JsonValue deserializedNull = MAPPER .readValue (serializedNull , JsonValue .class );
110
112
assertEquals (JsonValue .NULL , deserializedNull );
111
113
}
114
+
115
+ // for [datatype-jsr353#19]
116
+ public void testConstructorProperties () throws Exception
117
+ {
118
+ final String JSON = "{\" obj1\" :{}}" ;
119
+ ObjectImpl ob = MAPPER .readValue (JSON , ObjectImpl .class );
120
+ assertTrue (ob .obj1 instanceof JsonObject );
121
+ assertNull (ob .obj2 );
122
+ }
123
+
124
+ static class ObjectImpl {
125
+ JsonValue obj1 ;
126
+ JsonValue obj2 ;
127
+
128
+ @ ConstructorProperties ({"obj1" , "obj2" })
129
+ public ObjectImpl (JsonValue obj1 , JsonValue obj2 ) {
130
+ this .obj1 = obj1 ;
131
+ this .obj2 = obj2 ;
132
+ }
133
+ }
112
134
}
You can’t perform that action at this time.
0 commit comments