Serializing/Deserializing data betwee C++ and JavaScript endpoints with Google Protocol Buffer?Are there C++ equivalents for the Protocol Buffers delimited I/O functions in Java?Protocol buffers for JavaScript?Passing Protocol buffer serialized datas from C++ to Python via LevelDBGoogle Protocol Buffers - Storing messages into fileGoogle Protocol Buffer error: “Encountered string containing invalid UTF-8 data while serializing protocol buffer”Google Protocol Buffers in C++: Creating a message from an existing structCorrect way to invoke protocol buffer serialization with Nancy?Google Protocol Buffers C++ implementation stability and security in the face of malicious dataProtocol Buffers with dll programing c++Serializing/Deserializing Protocol Buffers

Help me, I hate squares!

"Fewer errors means better products" or fewer errors mean better products."

Can birds evolve without trees?

How can you tell the version of Ubuntu on a system in a .sh (bash) script?

How to get Planck length in meters to 6 decimal places

Can machine learning learn a function like finding maximum from a list?

Why does Latex make a small adjustment when I change section color

Should students have access to past exams or an exam bank?

What to expect in a jazz audition

How to calculate points under the curve?

How to remove rebar passing through an inaccessible pipe

Derivative is just speed of change?

If I buy and download a game through second Nintendo account do I own it on my main account too?

Was Donald Trump at ground zero helping out on 9-11?

Why is “deal 6 damage” a legit phrase?

How do discovery writers hibernate?

What does 「ちんちんかいかい」 mean?

Scam? Checks via Email

Prepare a user to perform an action before proceeding to the next step

How to innovate in OR

Why is the Searing Smite spell not listed in the Roll20 spell list?

What parameters are to be considered when choosing a MOSFET?

Translate the beginning of the blessing "Asher Yatzar"

What are these hats and the function of those wearing them? worn by the Russian imperial army at Borodino



Serializing/Deserializing data betwee C++ and JavaScript endpoints with Google Protocol Buffer?


Are there C++ equivalents for the Protocol Buffers delimited I/O functions in Java?Protocol buffers for JavaScript?Passing Protocol buffer serialized datas from C++ to Python via LevelDBGoogle Protocol Buffers - Storing messages into fileGoogle Protocol Buffer error: “Encountered string containing invalid UTF-8 data while serializing protocol buffer”Google Protocol Buffers in C++: Creating a message from an existing structCorrect way to invoke protocol buffer serialization with Nancy?Google Protocol Buffers C++ implementation stability and security in the face of malicious dataProtocol Buffers with dll programing c++Serializing/Deserializing Protocol Buffers






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I'm researching the possibility of serializing data via Google Protocol Buffers on a C++ application, sending the data to a JavaScript application, and deserializing the data for use by the JavaScript application. However, with no "ParseFromString()" function capability I'm not sure how this can be done and can't find any clear answer or example. How can this be done?



I'm using google-protobuf and proto3. I haven't tried much... truth is that I don't know where to even start. I would like to provide a MCVE but don't know how to with what I'm trying to achieve.



I've looked at "deserializeBinary" but I lost typing (deserializeBinary() required an "object" type param) when parsing the data from the received message. I'm using binary-parser for parsing the header from the serialized protocol buffer data.



// var msg == full received message from c++ server 
// which consists of 32 bit header
var parser = new Parser()
.uint16("header_val_1")
.uint16("header_val_2")
.string("msg_payload",
zeroTerminated: true
);
var msgObj = parser.parse(msg);
var payloadData = msgObj.msg_payload;
var newData = ProtoMsg.SpecialData.deserializeBinary(payloadData);
// throws type error (expects 'object')


I'd expect newData to be populated with the expected SpecialData message type so that it can checked for specific data points.



newData.getLength()



However that I can't get past the error and even then I'm not sure if I'm doing this right.










share|improve this question






























    1















    I'm researching the possibility of serializing data via Google Protocol Buffers on a C++ application, sending the data to a JavaScript application, and deserializing the data for use by the JavaScript application. However, with no "ParseFromString()" function capability I'm not sure how this can be done and can't find any clear answer or example. How can this be done?



    I'm using google-protobuf and proto3. I haven't tried much... truth is that I don't know where to even start. I would like to provide a MCVE but don't know how to with what I'm trying to achieve.



    I've looked at "deserializeBinary" but I lost typing (deserializeBinary() required an "object" type param) when parsing the data from the received message. I'm using binary-parser for parsing the header from the serialized protocol buffer data.



    // var msg == full received message from c++ server 
    // which consists of 32 bit header
    var parser = new Parser()
    .uint16("header_val_1")
    .uint16("header_val_2")
    .string("msg_payload",
    zeroTerminated: true
    );
    var msgObj = parser.parse(msg);
    var payloadData = msgObj.msg_payload;
    var newData = ProtoMsg.SpecialData.deserializeBinary(payloadData);
    // throws type error (expects 'object')


    I'd expect newData to be populated with the expected SpecialData message type so that it can checked for specific data points.



    newData.getLength()



    However that I can't get past the error and even then I'm not sure if I'm doing this right.










    share|improve this question


























      1












      1








      1








      I'm researching the possibility of serializing data via Google Protocol Buffers on a C++ application, sending the data to a JavaScript application, and deserializing the data for use by the JavaScript application. However, with no "ParseFromString()" function capability I'm not sure how this can be done and can't find any clear answer or example. How can this be done?



      I'm using google-protobuf and proto3. I haven't tried much... truth is that I don't know where to even start. I would like to provide a MCVE but don't know how to with what I'm trying to achieve.



      I've looked at "deserializeBinary" but I lost typing (deserializeBinary() required an "object" type param) when parsing the data from the received message. I'm using binary-parser for parsing the header from the serialized protocol buffer data.



      // var msg == full received message from c++ server 
      // which consists of 32 bit header
      var parser = new Parser()
      .uint16("header_val_1")
      .uint16("header_val_2")
      .string("msg_payload",
      zeroTerminated: true
      );
      var msgObj = parser.parse(msg);
      var payloadData = msgObj.msg_payload;
      var newData = ProtoMsg.SpecialData.deserializeBinary(payloadData);
      // throws type error (expects 'object')


      I'd expect newData to be populated with the expected SpecialData message type so that it can checked for specific data points.



      newData.getLength()



      However that I can't get past the error and even then I'm not sure if I'm doing this right.










      share|improve this question














      I'm researching the possibility of serializing data via Google Protocol Buffers on a C++ application, sending the data to a JavaScript application, and deserializing the data for use by the JavaScript application. However, with no "ParseFromString()" function capability I'm not sure how this can be done and can't find any clear answer or example. How can this be done?



      I'm using google-protobuf and proto3. I haven't tried much... truth is that I don't know where to even start. I would like to provide a MCVE but don't know how to with what I'm trying to achieve.



      I've looked at "deserializeBinary" but I lost typing (deserializeBinary() required an "object" type param) when parsing the data from the received message. I'm using binary-parser for parsing the header from the serialized protocol buffer data.



      // var msg == full received message from c++ server 
      // which consists of 32 bit header
      var parser = new Parser()
      .uint16("header_val_1")
      .uint16("header_val_2")
      .string("msg_payload",
      zeroTerminated: true
      );
      var msgObj = parser.parse(msg);
      var payloadData = msgObj.msg_payload;
      var newData = ProtoMsg.SpecialData.deserializeBinary(payloadData);
      // throws type error (expects 'object')


      I'd expect newData to be populated with the expected SpecialData message type so that it can checked for specific data points.



      newData.getLength()



      However that I can't get past the error and even then I'm not sure if I'm doing this right.







      javascript c++ reactjs protocol-buffers google-protocol-buffer






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 26 at 22:42









      FrankFrank

      8512 bronze badges




      8512 bronze badges

























          1 Answer
          1






          active

          oldest

          votes


















          0














          What you're doing can work. However, you should consider what data types are available in javascript. There are no 64 bit integers available. There are some third party javascript libraries available like jsbn for arbitrary precision numbers that could be used. binary-parser is a good choice but it cannot handle all the types required.



          You'd have to fill in the javascript column for this table and with javascript it will be tricky to cover everything.



          Secondly, writing a parser is no simple task, you'll have to follow all the rules in the encoding spec. It could be a lot of work.



          Protocol buffers are used primarily for performance, when compared to other options like json. But in the world of javascript, I suspect the performance will not be stellar, and you could have been better off using json which fits well with javascript.



          In any case, there actually exists protobuf support for js, it's not one of their primary supported languages but it's available. There is also another option. If you're still looking at writing your own, you could see how those implementations handled the challenges I've mentioned and other challenges that arise.






          share|improve this answer

























          • Thanks for the info. I think I was able to find a middle ground to solve my particular needs but can't be sure until I can link up with the C++ application for testing. I will update the question then. Thanks for your input!

            – Frank
            Mar 27 at 13:12










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55367219%2fserializing-deserializing-data-betwee-c-and-javascript-endpoints-with-google-p%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          What you're doing can work. However, you should consider what data types are available in javascript. There are no 64 bit integers available. There are some third party javascript libraries available like jsbn for arbitrary precision numbers that could be used. binary-parser is a good choice but it cannot handle all the types required.



          You'd have to fill in the javascript column for this table and with javascript it will be tricky to cover everything.



          Secondly, writing a parser is no simple task, you'll have to follow all the rules in the encoding spec. It could be a lot of work.



          Protocol buffers are used primarily for performance, when compared to other options like json. But in the world of javascript, I suspect the performance will not be stellar, and you could have been better off using json which fits well with javascript.



          In any case, there actually exists protobuf support for js, it's not one of their primary supported languages but it's available. There is also another option. If you're still looking at writing your own, you could see how those implementations handled the challenges I've mentioned and other challenges that arise.






          share|improve this answer

























          • Thanks for the info. I think I was able to find a middle ground to solve my particular needs but can't be sure until I can link up with the C++ application for testing. I will update the question then. Thanks for your input!

            – Frank
            Mar 27 at 13:12















          0














          What you're doing can work. However, you should consider what data types are available in javascript. There are no 64 bit integers available. There are some third party javascript libraries available like jsbn for arbitrary precision numbers that could be used. binary-parser is a good choice but it cannot handle all the types required.



          You'd have to fill in the javascript column for this table and with javascript it will be tricky to cover everything.



          Secondly, writing a parser is no simple task, you'll have to follow all the rules in the encoding spec. It could be a lot of work.



          Protocol buffers are used primarily for performance, when compared to other options like json. But in the world of javascript, I suspect the performance will not be stellar, and you could have been better off using json which fits well with javascript.



          In any case, there actually exists protobuf support for js, it's not one of their primary supported languages but it's available. There is also another option. If you're still looking at writing your own, you could see how those implementations handled the challenges I've mentioned and other challenges that arise.






          share|improve this answer

























          • Thanks for the info. I think I was able to find a middle ground to solve my particular needs but can't be sure until I can link up with the C++ application for testing. I will update the question then. Thanks for your input!

            – Frank
            Mar 27 at 13:12













          0












          0








          0







          What you're doing can work. However, you should consider what data types are available in javascript. There are no 64 bit integers available. There are some third party javascript libraries available like jsbn for arbitrary precision numbers that could be used. binary-parser is a good choice but it cannot handle all the types required.



          You'd have to fill in the javascript column for this table and with javascript it will be tricky to cover everything.



          Secondly, writing a parser is no simple task, you'll have to follow all the rules in the encoding spec. It could be a lot of work.



          Protocol buffers are used primarily for performance, when compared to other options like json. But in the world of javascript, I suspect the performance will not be stellar, and you could have been better off using json which fits well with javascript.



          In any case, there actually exists protobuf support for js, it's not one of their primary supported languages but it's available. There is also another option. If you're still looking at writing your own, you could see how those implementations handled the challenges I've mentioned and other challenges that arise.






          share|improve this answer













          What you're doing can work. However, you should consider what data types are available in javascript. There are no 64 bit integers available. There are some third party javascript libraries available like jsbn for arbitrary precision numbers that could be used. binary-parser is a good choice but it cannot handle all the types required.



          You'd have to fill in the javascript column for this table and with javascript it will be tricky to cover everything.



          Secondly, writing a parser is no simple task, you'll have to follow all the rules in the encoding spec. It could be a lot of work.



          Protocol buffers are used primarily for performance, when compared to other options like json. But in the world of javascript, I suspect the performance will not be stellar, and you could have been better off using json which fits well with javascript.



          In any case, there actually exists protobuf support for js, it's not one of their primary supported languages but it's available. There is also another option. If you're still looking at writing your own, you could see how those implementations handled the challenges I've mentioned and other challenges that arise.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 27 at 3:22









          Sean FSean F

          2,1766 silver badges14 bronze badges




          2,1766 silver badges14 bronze badges















          • Thanks for the info. I think I was able to find a middle ground to solve my particular needs but can't be sure until I can link up with the C++ application for testing. I will update the question then. Thanks for your input!

            – Frank
            Mar 27 at 13:12

















          • Thanks for the info. I think I was able to find a middle ground to solve my particular needs but can't be sure until I can link up with the C++ application for testing. I will update the question then. Thanks for your input!

            – Frank
            Mar 27 at 13:12
















          Thanks for the info. I think I was able to find a middle ground to solve my particular needs but can't be sure until I can link up with the C++ application for testing. I will update the question then. Thanks for your input!

          – Frank
          Mar 27 at 13:12





          Thanks for the info. I think I was able to find a middle ground to solve my particular needs but can't be sure until I can link up with the C++ application for testing. I will update the question then. Thanks for your input!

          – Frank
          Mar 27 at 13:12








          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid …


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55367219%2fserializing-deserializing-data-betwee-c-and-javascript-endpoints-with-google-p%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          How to preserve electronics (computers, tablets and phones) for hundreds of years Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) The network's official Twitter account is up and running again. What content…How might modern humans leave a message for 50,000 years?How would an aquatic race develop computers?How do we make computers care for human life?Keeping supplies for 1000 yearsWhat will cell phones become in 100 years?What body armor protects against a laser?Could a society attain 1800s technology if limited to using copper and bronze?Electricity power (magic) and electronicsScavenging metal resources in post-apocalypse after 100 yearsWhy would precursors create devices that can survive and still work after hundreds of years?

          155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해

          Convert JSON to MapSimplest way to convert a string representing JSON array into Java array List of key value pairsHow to take String JSON values into HashMapConvert a JSON String to a HashMapCreating BSON object from JSON stringJSONObject - How to get a value ?Better Map ConstructorReading JSON from Url javaUpdate columns if input values are not null otherwise ignore and keep the existing values of column in databaseHow to store object represented as Json string into Couchbase Lite?Go JSON into MapHow do I efficiently iterate over each entry in a Java Map?Sort a Map<Key, Value> by valuesHow to round a number to n decimal places in JavaCan comments be used in JSON?How do I read / convert an InputStream into a String in Java?How can I pretty-print JSON in a shell script?What is the correct JSON content type?How can I deserialize JSON to a simple Dictionary<string,string> in ASP.NET?Why does Google prepend while(1); to their JSON responses?Parse JSON in JavaScript?