File tree Expand file tree Collapse file tree 5 files changed +34
-1
lines changed
commercetools/commercetools-sdk-java-api/src
main/java/com/commercetools/api/json Expand file tree Collapse file tree 5 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -143,6 +143,9 @@ private TypeReference<?> typeRef(JsonNode valueNode) {
143
143
}
144
144
145
145
private ElemType elemType (JsonNode valueNode ) {
146
+ if (valueNode == null ) {
147
+ return ElemType .JSON_NODE ;
148
+ }
146
149
JsonNodeType valueNodeType = valueNode .getNodeType ();
147
150
switch (valueNodeType ) {
148
151
case OBJECT :
Original file line number Diff line number Diff line change 8
8
import java .time .LocalDate ;
9
9
import java .time .LocalTime ;
10
10
import java .time .ZonedDateTime ;
11
+ import java .util .List ;
11
12
import java .util .Map ;
12
13
13
14
import com .commercetools .api .models .common .LocalizedString ;
14
15
import com .commercetools .api .models .common .TypedMoney ;
16
+ import com .commercetools .api .models .order .Order ;
15
17
import com .commercetools .api .models .product .ProductReference ;
16
18
import com .commercetools .api .models .type .CustomFieldEnumValue ;
17
19
import com .commercetools .api .models .type .CustomFieldLocalizedEnumValue ;
@@ -70,5 +72,13 @@ public void fields() throws IOException {
70
72
number -> assertThat (number ).isEqualTo (11.0 ));
71
73
assertThat (fields .get ("set-reference" )).asList ().first ().isInstanceOf (ProductReference .class );
72
74
assertThat (fields .get ("set-money" )).asList ().first ().isInstanceOf (TypedMoney .class );
75
+ assertThat (fields .get ("set-empty" )).asList ().isEmpty ();
76
+ }
77
+
78
+ @ Test
79
+ public void emptyField () throws IOException {
80
+ Order order = JsonUtils .fromJsonString (stringFromResource ("orderlineitem.json" ), Order .class );
81
+
82
+ assertThat (order .getLineItems ().get (0 ).getCustom ().getFields ().values ().get ("empty" )).isInstanceOf (List .class );
73
83
}
74
84
}
Original file line number Diff line number Diff line change 153
153
}
154
154
]
155
155
]
156
+ },
157
+ {
158
+ "name" : " set-empty" ,
159
+ "value" : []
156
160
}
157
161
]
158
162
}
Original file line number Diff line number Diff line change 79
79
],
80
80
"set-boolean" : [
81
81
true
82
- ]
82
+ ],
83
+ "set-empty" : []
83
84
}
84
85
}
Original file line number Diff line number Diff line change
1
+ {
2
+ "lineItems" : [
3
+ {
4
+ "custom" : {
5
+ "type" : {
6
+ "typeId" : " type" ,
7
+ "id" : " 12345"
8
+ },
9
+ "fields" : {
10
+ "empty" : []
11
+ }
12
+ }
13
+ }
14
+ ]
15
+ }
You can’t perform that action at this time.
0 commit comments