# test.capnp
@0xd9e3377e4e6ce441;
struct Foo {
union {
a @0 :Void;
b @1 :Void;
}
}
// test.js
Capnp = require('capnp');
Foo = Capnp.import('test.capnp').Foo;
var foo = {b: false}; // any falsey value is allowed for a Void field.
var outputBuffer = Capnp.serialize(Foo, foo);
var obj = Capnp.parse(Foo, outputBuffer);
console.log(obj); // "{ b: null }", as expected
var outputBuffer2 = Capnp.serialize(Foo, obj);
var obj2 = Capnp.parse(Foo, outputBuffer2);
console.log(obj2); // "{ a: null }", not as expected; the value has changed!
It looks like this problem was introduced in https://github.com/kentonv/node-capnp/pull/17.