File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed
Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change 1+ # MessagePack for Java
2+
3+ ## How to install
4+
5+ You can install msgpack via maven:
6+
7+ <dependencies>
8+ ...
9+ <dependency>
10+ <groupId>org.msgpack</groupId>
11+ <artifactId>msgpack</artifactId>
12+ <version>${msgpack.version}</version>
13+ </dependency>
14+ ...
15+ </dependencies>
16+
17+ ## Simple Serialization/Deserialization/Duck Typing using Value
18+
19+ // Create serialize objects.
20+ List<String> src = new ArrayList<String>();
21+ src.add("msgpack");
22+ src.add("kumofs");
23+ src.add("viver");
24+
25+ MessagePack msgpack = new MessagePack();
26+ // Serialize
27+ byte[] raw = msgpack.write(src);
28+
29+ // Deserialize directly using a template
30+ List<String> dst1 = msgpack.read(raw, Templates.tList(Templates.TString));
31+ System.out.println(dst1.get(0));
32+ System.out.println(dst1.get(1));
33+ System.out.println(dst1.get(2));
34+
35+ // Or, Deserialze to Value then convert type.
36+ Value dynamic = msgpack.read(raw);
37+ List<String> dst2 = new Converter(dynamic)
38+ .read(Templates.tList(Templates.TString));
39+ System.out.println(dst2.get(0));
40+ System.out.println(dst2.get(1));
41+ System.out.println(dst2.get(2));
42+
43+
44+
You can’t perform that action at this time.
0 commit comments