GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — QuickStart

QuickStart

Jump to bottom Edit New page
Taro L. Saito edited this page May 22, 2020 · 20 revisions

Usage

pom.xml

<dependency>
   <groupId>org.msgpack</groupId>
   <artifactId>msgpack-core</artifactId>
   <version>(version)</version>
</dependency>
// Serialize with MessagePacker.
// MessageBufferPacker is an optimized version of MessagePacker for packing data into a byte array
MessageBufferPacker packer = MessagePack.newDefaultBufferPacker();
  packer
    .packInt(1)
    .packString("leo")
    .packArrayHeader(2)
    .packString("xxx-xxxx")
    .packString("yyy-yyyy");

byte[] msgpack = packer.toByteArray()

// Deserialize with MessageUnpacker
MessageUnpacker unpacker = MessagePack.newDefaultUnpacker(msgpack);
int id = unpacker.unpackInt();             // 1
String name = unpacker.unpackString();     // "leo"
int numPhones = unpacker.unpackArrayHeader();  // 2
String[] phones = new String[numPhones];
for (int i = 0; i < numPhones; ++i) {
  phones[i] = unpacker.unpackString();   // phones = {"xxx-xxxx", "yyy-yyyy"}
}
unpacker.close();

See also here for more advanced usages.

WHERE

Add a custom sidebar

Clone this wiki locally

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.