Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8867873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:08:33+00:00 2026-06-14T17:08:33+00:00

I am working on a Node.js application and I need to serialize and deserialize

  • 0

I am working on a Node.js application and I need to serialize and deserialize instances of the structs defined in an .thrift file, like the following:

 struct Notification {
   1: string subject,
   2: string message
 }

Now this is easy doable in Java, according to the tutorial at http://www.gettingcirrius.com/2011/03/rabbitmq-with-thrift-serialization.html :

    Notification notification = new Notification();
    TDeserializer deserializer = new TDeserializer();
    deserializer.deserialize(notification, serializedNotification);
    System.out.println("Received "+ notification.toString());

But I can’t find how this is done using the nodejs library of Thrift. Can anyone help, please?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T17:08:34+00:00Added an answer on June 14, 2026 at 5:08 pm

    Ok, after wasting a lot of time on research and trying different solutions, I finally came to the answer to my own question:

    //SERIALIZATION:
    var buffer = new Buffer(notification);
    var transport = new thrift.TFramedTransport(buffer);
    var binaryProt = new thrift.TBinaryProtocol(transport);
    notification.write(binaryProt);
    

    where notification is the object I wish to serialize. At this point, the byte array can be found in the transport.outBuffers field:
    var byteArray = transport.outBuffers;

    For deserialization:

    var tTransport = new thrift.TFramedTransport(byteArray);
    var tProtocol = new thrift.TBinaryProtocol(tTransport);
    var receivedNotif = new notification_type.Notification();
    receivedNotif.read(tProtocol);
    

    Assuming that the following lines have been added to the index.js file from the nodejs library for thrift:

    exports.TFramedTransport = require('./transport').TFramedTransport;
    exports.TBufferedTransport = require('./transport').TBufferedTransport;
    exports.TBinaryProtocol = require('./protocol').TBinaryProtocol;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a chat application with Node.js and Socket.io, and on disconnect, the
The following is the data I am working on: __DATA__ Node 1: 98 debug
I am working on pom file modifications to change the version node value. I
Working on a application which reads some values from an customers.xml file to UI.
I'm working on a test harness that interacts with another node application and verifies
I'm working on some project where I need some chat application. I decided to
In the application that I'm working on right now, I need to periodically check
I am working on asp.net application. I have a function like this: Public Function
I am working with a node.js application that uses Facebook APIs. In one part
I'm experimenting to get an Angular.js application working with Node.js. Currently I have the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.