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

Use MessagePack with unity in DLL

Simple question, I have made a dll that uses MessagePack (from nuget). Unfortunately it seems you cannot just drop the MessagePack dll directly into unity as it generates a bunch of errors. I was trying to find the best way to add message pack…
Matthew Goulart
  • 2,873
  • 4
  • 28
  • 63
0
votes
0 answers

Out of Memory during MessagePack Decoding

I'm running into out of memory issues when I attempt to decode MessagePack files using the msgpack-lite library in the browser. When run, the browser tab crashes (Chrome shows an 'Awww Snap!' error page). If I run the app with the developer tools…
Brian
  • 563
  • 1
  • 5
  • 15
0
votes
0 answers

How to add msgpack support in swagger rails

I am using swagger-docs in my rails app for API's documentation. It worked fine. Now I add msgpack in API response to speed up, that also works fine. But the issue I am facing now is that swagger-docs not unpack that response I send, due to which it…
Haseeb Ahmad
  • 7,914
  • 12
  • 55
  • 133
0
votes
2 answers

Using MessagePack with AspNet Core WebAPI and Console App

I am currently trying to implement MessagePack in a solution which contains 2 projects : AspNet Core WebAPI and a simple console app. The following package was added : How fo I Deserialize the object back on the client, here is the code snippets,…
Optimus Prime
  • 43
  • 1
  • 11
0
votes
0 answers

Fastest way to dump nested dict to the hard drive

I have a big (several Gigs) nested dictionary of this structure: { string1: {string1_1: int1_1, string1_2: int1_2, ...}, string2: {string2_1: int2_1, string2_2: int2_2, ...}, ... } Its a kind of word co-occurences counts in a big text corpus,…
Alexey Trofimov
  • 4,287
  • 1
  • 18
  • 27
0
votes
2 answers

JavaScript compare hex string from buffer to Python

I want to print a hex escaped sequence string from a Buffer. for instance: buffer = .... // => if I do: console.log(buffer.toString('hex')); I get: d3e952184ce777f7d7 but I want this representation with the \x…
Avba
  • 14,822
  • 20
  • 92
  • 192
0
votes
0 answers

How to concatenate a msgpack number with a regular string to create a redis key from node.js

I need to create a Redis key which is composed of a string and msgpack concatenated together. The key looks like this (in redis db): "a:b:c:\xcd\x10\xd8" The message pack portion is this: '\xcd\x10\xd8' (translates to 4312) my code is similar to…
Avba
  • 14,822
  • 20
  • 92
  • 192
0
votes
1 answer

Issue when decoding aerospike's msgpack in nodejs

I'm trying to decode bins' data returned by an aerospike get query using nodejs but i keep getting data containing weird \u0003 unicode characters. I have stored the data in aerospike using a simple script much like the default example 'use…
0
votes
2 answers

Packing ext type in C++ with Msgpack

I am looking for a sample how to pack ext types with msgpack in C++ as I am not sure about how to do this. The only information I found is located in this section https://github.com/msgpack/msgpack-c/wiki/v2_0_cpp_packer#pack-manually. Assumed I…
Robert_Jordan
  • 256
  • 4
  • 13
0
votes
1 answer

Use custom serializer like MessagePack with Phoenix Framework

Phoenix 1.3 Elixir 1.5.2 compiled with Erlang 20 I have an Android mobile app which sends and receives MsgPack with a HTTP server. Now we are planning to integrate Phoenix framework for some parts. But sending binaries specifically MsgPack is…
potatoPC
  • 67
  • 1
  • 8
0
votes
1 answer

Decode MsgPack payload with multiple item in java using msgpack-jackson

I'm trying to decode message pack payload. They payload is written in go with the following code var w bytes.Buffer testBatch := []Event{ exampleEvent, exampleEvent, } for _, e := range testBatch { data, err := e.MarshalMsg(nil) if…
ahmy
  • 4,095
  • 4
  • 27
  • 36
0
votes
1 answer

scala msgpack decimal values

Im using msgpack java with jackson serialization and its scala type conversions in a simple project. The msgpack is originally serialized in python and looks like price��5.0000� When i try to serialize in java or scala i get the following…
Sam Merry
  • 13
  • 7
0
votes
1 answer

Trying to get msgpack-cli to give me the same packed byte array as it does in JavaScript

In JavaScript, I can use msgpack to pack an object as follows: msgpack.pack(payload); Where payload is the following object: var payload = { event: "phx_join", payload: {}, ref: "1", topic: "players:1" }; When I call msgpack.pack(payload); on this…
Alexandru
  • 12,264
  • 17
  • 113
  • 208
0
votes
1 answer

How to serialize nested message with msg-pack in cpp?

How can I serialize a structure where a map is nested in a map - like the message below - using msg pack in cpp?: {"string": "string", "string": {"string": int, "string": int, "string": int} }
eggman
  • 3
  • 3
0
votes
1 answer

How to reduce compile times with Msgpack in c++?

I have found it useful to be able to serialize user-defined structs. I usually use something like #include struct MyStruct { int val; MSGPACK_DEFINE_MAP(val); }; This will then get included anywhere that needs it. I later…
sardine
  • 13
  • 5