Questions tagged [msgpack]

MessagePack is a binary-based efficient object serialization library. It enables to exchange structured objects between many languages like JSON. But unlike JSON, it is very fast and small.

MessagePack is a binary-based efficient object serialization library. It enables to exchange structured objects between many languages like JSON. But unlike JSON, it is very fast and small.

Typical small integer (like flags or error code) is saved only in 1 byte, and typical short string only needs 1 byte except the length of the string itself. [1,2,3] (3 elements array) is serialized in 4 bytes using MessagePack as follows:

> require 'msgpack'
> msg = [1,2,3].to_msgpack  #=> "\x93\x01\x02\x03"
> MessagePack.unpack(msg)   #=> [1,2,3]

Scalable RPC

MessagePack-RPC is cross-language RPC library for client, server and cluster applications. Because it releases you from complicated network programming completely and provides well-designed API, you can easily implement advanced network applications with MessagePack-RPC.

require 'msgpack/rpc'
class MyHandler
  def add(x,y) return x+y end
end
svr = MessagePack::RPC::Server.new
svr.listen('0.0.0.0', 18800, MyHandler.new)
svr.run

require 'msgpack/rpc'
c = MessagePack::RPC::Client.new('127.0.0.1',18800)
result = c.call(:add, 1, 2)  #=> 3

MessagePack is available for many languages:

  • C
  • C++
  • D
  • Erlang
  • Go
  • Haskell
  • Java
  • OCaml
  • Python
  • Perl
  • PHP
  • Ruby
  • Scala
409 questions
0
votes
0 answers

msgpack: Pack a tuple in Python and unpack it in Java

I am trying to send a tuple from Python to Java using msgpack but I do not seem to be able of doing it This is the code in Python tuple_data = (12, "ajonjoli", 554) new_file = open("/tmp/tuple_ser.bin", "wb") msgpack.pack(tuple_data,…
JAC
  • 287
  • 1
  • 10
0
votes
1 answer

How to make into Buffer? - Trying to decode MessagePack Axios response to JSON or JavaScript Object notation

I'm trying to decode a MessagePack response from a backend call using Axios that looks like this: ��matches����attendance��away_team�� etc. into a format where I can access its contents (e.g. JSON or JavaScript Object). Simply using msgpack-lite's…
shaotime
  • 39
  • 1
  • 3
0
votes
2 answers

Axios GET on a MessagePack formatted data

I'm attempting to use Axios to GET some data from a backend. The data is usually returned in MessagePack form, but Axios auto-parses the data into what I believe is JSON. However, the response data appears to have a "%" sign in front of every entry…
shaotime
  • 39
  • 1
  • 3
0
votes
1 answer

Can't compile SignalR+TypeScript with MessagePack plugin

I've been successful by creating a small app using AspNetCore 2.2, SignalR, and a TypeScript front-end. The bundle is created via WebPack. What I would like to try is to enable the MessagePack protocol plugin. However, the docs about how to install…
Mario Vernari
  • 6,649
  • 1
  • 32
  • 44
0
votes
1 answer

Packing a polymorphous class structure with msgpack

I want to pack my C++ class structure with msgpack using some polymorphous mechanism to apply code packing base classes only once. Currently, I am packing the data twice, in the base class and in the subclass. This is my current status: class Base…
Robert_Jordan
  • 256
  • 4
  • 13
0
votes
1 answer

msgpack gets string data back as binary

In How do I read and write with msgpack? an answer ( https://stackoverflow.com/a/43442195 ) is given how to dump data to disk and read it back. I had to adapt the answer given there (namely: add the "b" option for reading and writing) to get it…
user7468395
  • 1,299
  • 2
  • 10
  • 23
0
votes
1 answer

Getting byte offsets in msgpack 0.6

In my scenario I need to allow random access to single items serialized with msgpack. I.e. given a binary file and an item index, I want to jump to exactly that position in the file and deserialize this item. To get the byte offset to each item I…
Zwackelmann
  • 557
  • 1
  • 5
  • 19
0
votes
1 answer

Google Cloud Function Python package not installed through requirements.txt

I m trying to deploy a python cloud function to GCP that uses the package msgpack (I already successfully deployed many cloud functions before so I m pretty much used to the process). So I got my requirements.txt containing msgpack but the…
0
votes
1 answer

Different outputs for byte objects with escape sequences (Python Pandas Msgpack)

Python represents escape sequences with \ as I understand. So if I tryo to insert a single backslash into a string, I get the string variable with double backslashes as below: x = '/x91/x84/xa4/x74' b = x.replace(r'/', '\\') >>>…
0
votes
0 answers

How to convert a tabular format or python dataframe-equivalent format to msgpack format in C++

(Please Note: I am not able to embed images here. I dont have enough points for that. Could anyone please help me with that.) I understand how to convert the struct corresponding to the following tablular format (Struct1) into msgpack…
0
votes
2 answers

Create outlook draft email in python with out launching outlook application

I need to create an email draft and save in msg format without launching the outlook application. (Or) I have an existing draft msg file, I need to modify the sender, body, and attachment to that file and save as msg file. I tried win32 it is…
srikanth nagineni
  • 431
  • 1
  • 6
  • 16
0
votes
1 answer

Java - The method newDefaultUnpacker(byte[]) is undefined for the type MessagePack

I'm trying to use the newDefaultUnpacker static method of the MessagePack class like this: import org.msgpack.MessagePack; Map map = MessagePack.newDefaultUnpacker(myByteArray).unpackValue().asMapValue().map(); however I get the…
Chris Halcrow
  • 28,994
  • 18
  • 176
  • 206
0
votes
1 answer

JMeter benchmark JSON vs MessagePack

I want using JMeter to benchmark server to server communication (Java Spring) with different data serialization format than JSON Article Why not JSON? is suggesting MessagePack MessagePack is an efficient binary serialization format. It lets you…
Ori Marko
  • 56,308
  • 23
  • 131
  • 233
0
votes
2 answers

RPC over TCP with multiple clients on same machine

I'm building an RPC Server in golang that uses msgpack. The client is built in python using the mprpc library (msgpack over TCP with gevent). My issue is, being an absolute noob in networking, I discovered that I can't use the same address/port…
Tuft
  • 27
  • 8
0
votes
0 answers

distributed 1.21.8 requires msgpack, which is not installed even after suggested fixes

Any idea why this error occurs? I'm inside a virtual environment I created in anaconda3, using MAC. I tried several fixes from previous threads but it didn't work. (env)iMac.local:~$pip install --upgrade pip Requirement already up-to-date:…
Cranjis
  • 1,590
  • 8
  • 31
  • 64