Bitbucket is a code hosting site with unlimited public and private repositories. We're also free for small teams!

Close
Alternate msppack implementation for Java.

This implementation complements the standard msgpack library for Java:
	https://github.com/msgpack/msgpack-java

Main differences:
	- (Much) Simpler API
	- No external dependencies
	- No builtin support for native object serialization, annotations, or RPC.
	- It's very minimalistic - at the time of this writing, the entire redistributable
	  library is only ~11kb ... with full library sources for reference.
	
Usage: 
import net.asdfa.msgpack;
...
List<Object> objects = Arrays.asList("potatoes", false, 11, null);
//pack it:
byte[] data = MsgPack.pack(objects);

//unpack it:
Object unpacked = MsgPack.unpack(data);
System.out.println("Unpacked data: " + unpacked);


See Test.java for more examples.
You can also pack/unpack to/from Data(Output/Input)Streams.
You can also specify unpacking options:
    Object unpacked = MsgPack.unpack(data, UNPACK_RAW_AS_STRING);
  to unpack things as something other than a raw byte[].

Types:
This implementation uses the builtin Java types:
 - null
 - Boolean
 - Number (byte, short, int, and long are considered interchangeable when packing/unpacking, other considerations)
 - String (UTF-8), byte[], or ByteBuffer (the *whole* buffer) (always unpacked as a ByteBuffer)
 - Map (any type may be used for packing, always unpacked as a HashMap)
 - List (any type may be used for packing, always unpacked as an ArrayList)
Passing any other type to MsgPack.pack() will throw an IllegalArumentException.

Note that the implementation does no recursion checks - If you pass a cyclic object
it will hang in an infinite loop.




Recent activity

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.