Skip to content

Commit 1723e67

Browse files
authored
fix: Mapping of ArrayNode (#22144)
Transform ArrayNode to JsonArray correctly. Handle NullNode correctly.
1 parent 6c6e3d6 commit 1723e67

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

flow-server/src/main/java/com/vaadin/flow/internal/change/MapPutChange.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@
2020
import com.fasterxml.jackson.databind.node.ArrayNode;
2121
import com.fasterxml.jackson.databind.node.BaseJsonNode;
2222
import com.fasterxml.jackson.databind.node.BooleanNode;
23+
import com.fasterxml.jackson.databind.node.NullNode;
2324
import com.fasterxml.jackson.databind.node.NumericNode;
2425
import com.fasterxml.jackson.databind.node.ObjectNode;
2526
import com.fasterxml.jackson.databind.node.TextNode;
2627
import com.fasterxml.jackson.databind.node.ValueNode;
2728

2829
import com.vaadin.flow.internal.ConstantPool;
2930
import com.vaadin.flow.internal.JacksonCodec;
31+
import com.vaadin.flow.internal.JacksonUtils;
3032
import com.vaadin.flow.internal.JsonCodec;
3133
import com.vaadin.flow.internal.StateNode;
3234
import com.vaadin.flow.internal.nodefeature.NodeFeature;
@@ -100,6 +102,9 @@ protected void populateJson(JsonObject json, ConstantPool constantPool) {
100102
} else if (value instanceof ObjectNode node) {
101103
json.put(JsonConstants.CHANGE_PUT_VALUE, Json.parse(JacksonCodec
102104
.encodeWithConstantPool(node, constantPool).toString()));
105+
} else if (value instanceof NullNode) {
106+
json.put(JsonConstants.CHANGE_PUT_VALUE,
107+
JsonCodec.encodeWithConstantPool(null, constantPool));
103108
} else if (value instanceof NumericNode node) {
104109
json.put(JsonConstants.CHANGE_PUT_VALUE, Json.create(JacksonCodec
105110
.encodeWithConstantPool(node, constantPool).doubleValue()));
@@ -111,9 +116,13 @@ protected void populateJson(JsonObject json, ConstantPool constantPool) {
111116
} else if (value instanceof TextNode node) {
112117
json.put(JsonConstants.CHANGE_PUT_VALUE, Json.create(JacksonCodec
113118
.encodeWithConstantPool(node, constantPool).textValue()));
114-
} else if (value instanceof BaseJsonNode node) {
119+
} else if (value instanceof ValueNode node) {
115120
json.put(JsonConstants.CHANGE_PUT_VALUE, Json.create(JacksonCodec
116121
.encodeWithConstantPool(node, constantPool).toString()));
122+
} else if (value instanceof ArrayNode node) {
123+
json.put(JsonConstants.CHANGE_PUT_VALUE,
124+
JacksonUtils.createElementalArray((ArrayNode) JacksonCodec
125+
.encodeWithConstantPool(node, constantPool)));
117126
} else {
118127
json.put(JsonConstants.CHANGE_PUT_VALUE,
119128
JsonCodec.encodeWithConstantPool(value, constantPool));

0 commit comments

Comments
 (0)