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
4
votes
1 answer

Decoding msgpack_numpy with utf-8 strings

I use python 3.6 with msgpack==0.5.1 and msgpack_numpy==0.4.2. When trying to encode and decode a dict, the string needs to be handled using utf-8 to restore the dict's keys as strings (instead of binaries). For example: import msgpack d = {'key':…
Liran Funaro
  • 2,750
  • 2
  • 22
  • 33
4
votes
1 answer

using msgpack to encode a user-defined structure.

Im trying to work with msgpack. I have a receiver and a sender. Sender is a c++ client and the receiver is an erlang server. Msgpack was totally great when I had an erlang server and an erlang client. I used to send and receive datatypes like…
sad
  • 820
  • 1
  • 9
  • 16
4
votes
1 answer

How do I decode a msgpack file in Python?

I've created a msgpack file from a Pandas Dataframe, using the following code: df.to_msgpack('ixto.msg') I've confirmed that the file is saved in the directory, but I can't use msgpack library for python since the following code: unp =…
Hugo
  • 1,558
  • 12
  • 35
  • 68
4
votes
3 answers

MessagePack and datetime

I need a fast way to send 300 short messages a second over zeromq between the python multiprocessing processes. Each message needs to contain an ID and time.time() msgpack seems like the best way to serialize the dict before sending it via zeromq,…
Bart
  • 524
  • 7
  • 17
4
votes
1 answer

msgpack: haskell & python

I'm confused by the differences between haskell and python clients for msgpack. This: import Data.MessagePack as MP import Data.ByteString.Lazy as BL BL.writeFile "test_haskell" $ MP.pack (0, 2, 28, ()) and this: import msgpack with…
erthalion
  • 3,094
  • 2
  • 21
  • 28
4
votes
1 answer

Javassist Runtime Error with msgpack-java

I am trying to use messagepack to send data back and forth between an Arduino and a Java application, and I am having trouble setting up the java implementation of messagepack: msgpack-java…
4
votes
3 answers

MessagePack, c++: How to use MSGPACK_DEFINE with c++11 enum classes

The following sample does not compile, complaining that In file included from /usr/include/msgpack.hpp:18: /usr/include/msgpack/object.hpp:211:3: error: member reference base type 'logd::log_level' is not a structure or union and a corresponding…
justinzane
  • 1,897
  • 1
  • 26
  • 38
4
votes
0 answers

How to use msgpack instead of pickle for logging SocketHandler in Python?

The Logging Cookbook describes a method for using Python logging functionality with remote log server. Unfortunately, this implementation requires exposing of the server, which process the received data with unPickle function, which is a severe…
wzab
  • 788
  • 7
  • 24
4
votes
1 answer

How can I extend jQuery's $.ajax to support new content types?

I would like to be able to send and receive MessagePack-formatted data with jQuery's $.ajax(). How does one extend $.ajax() to support new Content-Type formats?
David Eyk
  • 12,171
  • 11
  • 63
  • 103
4
votes
1 answer

ServiceStack MsgPackServiceClient fails when fetching data but JsonServiceClient works

I'm playing around with ServiceStack and doing baby steps trying to understand the technology. I've got a very simple setup (complete solution is available for download): Stand alone AppHost using ServiceStack (self-hosted) I launch the server then…
Renaud Bompuis
  • 16,596
  • 4
  • 56
  • 86
4
votes
1 answer

msgpack: messaging between C++ and java

I have two applications (one written in C++ and other in Java). I use msgpack to pack the C++ class to the binary format. Then I send this to the Java side. I wonder if I unpack this message in java (using msgpack too) do I get the correct Java…
maverik
  • 5,508
  • 3
  • 35
  • 55
4
votes
2 answers

Serializing with Messagepack

I like to serialize my java class object using Messagepack. My class structure is such that public class A { private InnerClass obj; //Some other variables with getters and setters. // There will be a getter and setter for obj(InnerClass)…
Muzy
  • 505
  • 2
  • 6
  • 16
3
votes
1 answer

Parse messagePack to Json with python

I have that buffer 87 a1 41 a4 31 32 33 34 a1 42 a4 61 62 63 64 a1 43 a1 61 a1 44 a8 31 31 31 31 31 31 31 31 a1 45 a8 75 73 65 72 6e 61 6d 65 a1 46 a4 6e 61 6d 65 a1 47 a7 6e 61 6d 65 5f 6e 61 and I want to parse to this json { "A": "1234", …
vtable
  • 302
  • 2
  • 15
3
votes
1 answer

I would like to parse a boost::beast::flat_buffer with msgpack data using nlohmann:json

So I am using boost::beast as a WebSocket server. I would like to receive a binary message and parse it using nlohmann::json. However I get an error message: none of the 3 overloads can convert parameter "nlohmann::detail::input_adapter" Here is…
Ray Hulha
  • 10,701
  • 5
  • 53
  • 53
3
votes
3 answers

How to send BytesIO using requests post

I am trying to send msgpack encoded values to server using requests post to an insert rest endpoint which takes the serialized byte stream as input. But it seems like the values are not getting there properly as I see no values getting inserted in…
ShellZero
  • 4,415
  • 12
  • 38
  • 56