I replied on your GitHub issue here:
https://github.com/protocolbuffers/protobuf/issues/6479

On Mon, Aug 5, 2019 at 11:44 PM A <[email protected]> wrote:

> I'm trying to dump the protobuf message object using MessageToJsonString() 
> function
> but encountering an exception. Sample code is as below followed by the
> output without try{}catch()
>
>
> ResultRecord* GetSampleData()
> {
>     auto resultRecord = std::make_unique<ResultRecord>();
>     ....
>     //Filling resultRecord
>     ....
>     return resultRecord.release();
> }
> int main(int, char**) {
>
>     //Getting RecordData through Protobuf
>     auto data = GetSampleData();
>
>     if(data){
>         std::string str;
>         google::protobuf::util::JsonOptions opts;
>         opts.add_whitespace = true;
>         try{
>             google::protobuf::util::MessageToJsonString(*(data), &str, opts);
>         }
>         catch(std::exception e)
>         {
>             std::cout<< e.what()<<std::endl;
>         }
>         std::cout<<str<<std::endl;
>     }
>     return 0;
> }
>
> Output :
>
> terminate called after throwing an instance of 'std::system_error'
>   what():  Unknown error -1
>
> I'm not sure what to do to debug this. Can someone point me in right
> direction ?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/protobuf/e4f70f39-40cb-4801-9c96-da46e3dd3830%40googlegroups.com
> <https://groups.google.com/d/msgid/protobuf/e4f70f39-40cb-4801-9c96-da46e3dd3830%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/CADqAXr5xm6%2BzyEjyiP%3Dzp%2BYDJit1438EDiuL3d5Nk55FL9rCdA%40mail.gmail.com.

Reply via email to