Questions tagged [messagepack]

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.

http://msgpack.org/

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
72 questions
3
votes
3 answers

MessagePack implementation for Objective-C

Is there an implementation of the MessagePack protocol for Objective-C? If not, are there examples for bridging the C implementation to Objective-C types?
Bradley Dwyer
  • 8,102
  • 5
  • 32
  • 28
3
votes
0 answers

How to efficiently serialize primitive arrays with Message Pack?

Message Pack formats can serialize small integers or short strings in a compact way that merges type identifier with actual data. Now when the data to serialize contains a primitive array (Java double[] for instance) then the Message Pack…
Antoine CHAMBILLE
  • 1,676
  • 2
  • 13
  • 29
3
votes
1 answer

Sending data through ZeroMQ (zmqpp) using MsgPack gives 'msgpack::v1::insufficient_bytes' error

I made a PUB/SUB connection using zmqpp and now I want to send data from the publisher to the subscribers using the header-only, C++11 version of msgpack-c. The publisher has to send 2 int64_t numbers -- header_1 and header_2 -- followed by a…
maddouri
  • 3,737
  • 5
  • 29
  • 51
3
votes
1 answer

Sending a vector through zeromq with msgpack

I can't seem to send a vector of a struct that I serialized with msgpack through ZeroMQ. It's a vector of this struct: struct MyData { MyData() : id(0), x(0), y(0), a(0) {} MyData(const Obj &r) : id(0), x(r.pose[0]), y(r.pose[1]),…
noko
  • 1,129
  • 2
  • 14
  • 25
3
votes
1 answer

using MsgPack with Servicestack: how do I do KnownType?

I'm attempting to support the MessagePack protocol in my current Servicestack implementation. I need it to support (de)serializing a list of ISegment defined like this: [KnownType(typeof(ArcSegment)), KnownType(typeof(LineSegment))] public class…
Brannon
  • 5,324
  • 4
  • 35
  • 83
3
votes
2 answers

MessagePack Serializing object error on Android

use messagepack on android, the can serialize/deserialize a class, but not absolutely right . the simple test class: @Message public class Account { public String Code; public int Sequence; public float Lot; public String…
3
votes
1 answer

MessagePack C API

In looking at the C API for MessagePack, there are a number of functions to appropriately serialize (pack) the data according to type: msgpack_pack_uint8, msgpack_pack_int32, ... There doesn't seem to be the equivalent call in the API to unpack the…
CNK
  • 1,053
  • 2
  • 11
  • 17
2
votes
2 answers

How to invoke a MessagePack RPC service from Javascript?

I've got this simple Java server process running as a MessagePack RPC service. I want to invoke the hello() service from Javascript, not Java, but have yet to find an example on how to achieve it. There does not appear to be a RPC implementation for…
raffian
  • 31,267
  • 26
  • 103
  • 174
2
votes
1 answer

Unable to deserialize service response when using servicestack MsgPack client

Am getting below error when trying to deserialize the response from the service while using servicestack MsgPackServiceClient. Exception: {"Cannot deserialize member 'test1' of type 'System.Int32'."} InnerException : {"Cannot convert 'System.Int32'…
Shan
  • 131
  • 7
2
votes
1 answer

Interoperability problems python2 python3

Two uServices are communicating via a message queue (RabbitMQ). The data is encoded using message pack. I have the following scenarios: python3 -> python3: working fine python2 -> python3: encoding issues Encoding is done…
blueFast
  • 41,341
  • 63
  • 198
  • 344
2
votes
3 answers

Comparing null-terminated string with a non null-terminated string in C

The deserialization library (messagepack) I am using does not provide null-terminated strings. Instead, I get a pointer to the beginning of the string and a length. What is the fastest way to compare this string to a normal null-terminated string?
weiyin
  • 6,819
  • 4
  • 47
  • 58
2
votes
1 answer

Using MsgPack custom serializer in C# application

I am experiencing difficulties with using MsgPack custom serializer in C#. Say, I have the following class: public class A { public int intA; public string strA; public B nestedB; } public class B { public string strB; public…
Yuri Girba
  • 31
  • 4
2
votes
1 answer

In messagepack, error while getting value from MapValue.. Please help me

I'm trying to serialize map using messagpack.write(map). During deserialization using messagepack.read(byte[]) i got MapValue. But I cannot fetch the values using MapValue.get(key). Look this problem below HashMap map = new…
user2641906
  • 93
  • 1
  • 10
2
votes
1 answer

How to use Data.MessagePack in Haskell

MessagePack is a binary serialization format, which apparently can be used from both Haskell and Python, languages that I need to mix in a project of mine. The structures that I need to serialize are fairly trivial: data Citation = Citation { …
dsign
  • 12,340
  • 6
  • 59
  • 82
2
votes
0 answers

msgpack deserialize c++

When I parse from the buffer, I have to know,what the exact class type(myclass) of the buffer is. So I cant handle all the buffer parse in an uniform way. I have to distinguish every class type(can I?). My questions is "how can i handle all the…
sinopec
  • 851
  • 1
  • 9
  • 16