Is the Json Decoder supposed to be able to parse Void fields in a union
member?
Given
struct TestDistinguishVoidsInUnion {
union {
first @0 :Void;
second @1 :Void;
}
}
the following test fails (Windows, v0.6.0):
KJ_TEST("decode voids in union") {
MallocMessageBuilder message;
auto root = message.initRoot<test::TestDistinguishVoidsInUnion>();
JsonCodec json;
json.decode("{\"first\":null}", root);
KJ_EXPECT(root.isFirst() == true);
json.decode("{\"second\":null}", root);
KJ_EXPECT(root.isSecond() == true); //<-- this fails
}
The encoding seems to work fine:
KJ_TEST("encode voids in union") {
MallocMessageBuilder message;
auto root = message.getRoot<test::TestDistinguishVoidsInUnion>();
JsonCodec json;
root.setFirst();
auto encoded = json.encode(root);
KJ_EXPECT(encoded == "{\"first\":null}");
root.setSecond();
encoded = json.encode(root);
KJ_EXPECT(encoded == "{\"second\":null}");
}
Thanks!
Stijn
--
You received this message because you are subscribed to the Google Groups
"Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
Visit this group at https://groups.google.com/group/capnproto.