Skip to content

Commit cd4f860

Browse files
author
Mark
committed
fixed VPack serializing of array with null values (issue #88)
1 parent 8b264e5 commit cd4f860

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/main/java/com/arangodb/velocypack/VPack.java

+2
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,8 @@ private void serializeArray(
623623
final Object element = Array.get(value, i);
624624
if (element != null) {
625625
addValue(null, element.getClass(), element, builder, null, additionalFields);
626+
} else {
627+
builder.add(ValueType.NULL);
626628
}
627629
}
628630
builder.close();

src/test/java/com/arangodb/velocypack/VPackSerializeDeserializeTest.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -692,9 +692,10 @@ public void fromArrayWithNull() {
692692

693693
final VPackSlice a1 = vpack.get("a1");
694694
assertThat(a1.isArray(), is(true));
695-
assertThat(a1.size(), is(1));
695+
assertThat(a1.size(), is(2));
696696
assertThat(a1.get(0).isString(), is(true));
697697
assertThat(a1.get(0).getAsString(), is("foo"));
698+
assertThat(a1.get(1).isNull(), is(true));
698699
}
699700

700701
protected enum TestEnum {

0 commit comments

Comments
 (0)