Skip to content

Commit a34087a

Browse files
author
mpv1989
committed
Fix docs
1 parent 71101d6 commit a34087a

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

README.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ mvn clean install -DskipTests=true -Dgpg.skip=true -Dmaven.javadoc.skip=true -B
6969
* [Java 8 types](#java-8-types)
7070
* [Scala types](#scala-types)
7171
* [Joda-Time](#joda-time)
72-
* custom de-/serializer
72+
* [custom serializer](#custom-serializer)
7373
* [Manipulating databases](#manipulating-databases)
7474
* [create database](#create-database)
7575
* [drop database](#drop-database)
@@ -265,6 +265,36 @@ Added support for:
265265
ArangoDB arangoDB = new ArangoDB.Builder().registerModule(new VPackJodaModule()).build();
266266
```
267267

268+
## custom serializer
269+
``` Java
270+
ArangoDB arangoDB = new ArangoDB.Builder()
271+
.registerDeserializer(MyObject.class, new VPackDeserializer<MyObject>() {
272+
@Override
273+
public MyObject deserialize(
274+
final VPackSlice parent,
275+
final VPackSlice vpack,
276+
final VPackDeserializationContext context) throws VPackException {
277+
278+
final MyObject obj = new MyObject();
279+
obj.setName(vpack.get("name").getAsString());
280+
return obj;
281+
}
282+
}).registerSerializer(MyObject.class, new VPackSerializer<MyObject>() {
283+
@Override
284+
public void serialize(
285+
final VPackBuilder builder,
286+
final String attribute,
287+
final MyObject value,
288+
final VPackSerializationContext context) throws VPackException {
289+
290+
builder.add(attribute, ValueType.OBJECT);
291+
builder.add("name", value.getName());
292+
builder.close();
293+
}
294+
}).build();
295+
```
296+
297+
268298
# Manipulating databases
269299

270300
## create database

0 commit comments

Comments
 (0)