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

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript