Hi Krzystof, The parameter to encode() should be a specific typed Reader, not a MessageReader. So, something like:
capnp::JsonCodec json; kj::String json_encoded = json.encode(builder.getRoot< MyStructType>().asReader()); -Kenton On Thu, Mar 1, 2018 at 1:50 PM, Krzysztof Sakrejda < [email protected]> wrote: > I'm looking for a suggestion about where to look next for fixing this > issue. With these three lines I get a compilation failure: > > capnp::JsonCodec json; > capnp::SegmentArrayMessageReader reader(builder.getSegmentsForOutput > ()); > kj::String json_encoded = json.encode(reader); > > > The failure is on the third line, I'm failing to see if I did something > wrong or if there are caveats to the JSON > encode function that I'm missing. These are schema I can already write > out to a binary stream successfully and > read back so I think those are ok. > > Here's the compiler message: > > [ 83%] Building CXX object src/capnstan/CMakeFiles/config_writer.dir/ > config_writer.cpp.o > In file included from /home/krzysztof/packages/capnStan/downloads/ > capnproto-c++/src/capnp/raw-schema.h:29:0, > from /home/krzysztof/packages/capnStan/capnStan/../ > downloads/capnproto-c++/src/capnp/generated-header-support.h:31, > from /home/krzysztof/packages/capnStan/capnStan/src/capnp > /stan-config.capnp.h:7, > from /home/krzysztof/packages/capnStan/capnStan/src/ > capnstan/config_switch.hpp:34, > from /home/krzysztof/packages/capnStan/capnStan/src/ > capnstan/config_writer.cpp:1: > /home/krzysztof/packages/capnStan/downloads/capnproto-c++/src/capnp/common > .h: In substitution of ‘template<class T> using FromAny = typename capnp:: > FromAny_<T>::Type [with T = kj::Decay_<capnp::SegmentArrayMessageReader > &>::Type]’: > /home/krzysztof/packages/capnStan/capnStan/../downloads/capnproto-c++/src/ > capnp/compat/json.h:215:33: required from ‘kj::String capnp::JsonCodec:: > encode(T&&) [with T = capnp::SegmentArrayMessageReader&]’ > /home/krzysztof/packages/capnStan/capnStan/src/capnstan/config_writer.cpp: > 26:51: required from here > /home/krzysztof/packages/capnStan/downloads/capnproto-c++/src/capnp/common > .h:290:43: error: invalid use of incomplete type ‘struct capnp::FromAny_< > capnp::SegmentArrayMessageReader, void>’ > using FromAny = typename FromAny_<T>::Type; > ^ > /home/krzysztof/packages/capnStan/downloads/capnproto-c++/src/capnp/common > .h:256:8: note: declaration of ‘struct capnp::FromAny_<capnp::Segment > ArrayMessageReader, void>’ > struct FromAny_; > ^~~~~~~~ > > > > -- > 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. > -- 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.
