Repository: johnzon
Updated Branches:
  refs/heads/master 562d9e8ae -> 7f4155d30


JOHNZON-135 add proper JavaDocs for setDeduplicateObjects


Project: http://git-wip-us.apache.org/repos/asf/johnzon/repo
Commit: http://git-wip-us.apache.org/repos/asf/johnzon/commit/34145fe3
Tree: http://git-wip-us.apache.org/repos/asf/johnzon/tree/34145fe3
Diff: http://git-wip-us.apache.org/repos/asf/johnzon/diff/34145fe3

Branch: refs/heads/master
Commit: 34145fe3d8398459b09eb65209ac94ea62bcb992
Parents: 562d9e8
Author: Mark Struberg <[email protected]>
Authored: Tue Sep 26 13:08:59 2017 +0200
Committer: Mark Struberg <[email protected]>
Committed: Tue Sep 26 13:08:59 2017 +0200

----------------------------------------------------------------------
 .../apache/johnzon/mapper/MapperBuilder.java    | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/johnzon/blob/34145fe3/johnzon-mapper/src/main/java/org/apache/johnzon/mapper/MapperBuilder.java
----------------------------------------------------------------------
diff --git 
a/johnzon-mapper/src/main/java/org/apache/johnzon/mapper/MapperBuilder.java 
b/johnzon-mapper/src/main/java/org/apache/johnzon/mapper/MapperBuilder.java
index d8998cd..3c90309 100644
--- a/johnzon-mapper/src/main/java/org/apache/johnzon/mapper/MapperBuilder.java
+++ b/johnzon-mapper/src/main/java/org/apache/johnzon/mapper/MapperBuilder.java
@@ -422,7 +422,27 @@ public class MapperBuilder {
     /**
      * If any non-primitive Java Object gets serialised more than just one 
time,
      * then we write a JsonPointer to the first occurrence instead.
+     *
      * This will effectively also avoid endless loops in data with cycles!
+     *
+     * An example: Assume you have a Person with a name 'Sarah' and her 
daughter,
+     * a Person with the name 'Clemens' both stored in a JSON array.
+     * Given the Java Code:
+     * <pre>
+     * Person sarah = new Person("Sarah");
+     * Person clemens = new Person("Clemens");
+     * clemens.setMother(sarah);
+     * Person[] family = new Person[]{sarah, clemens};
+     * </pre>
+     * Transformed to JSON this will now look like the following:
+     * <pre>
+     * [{"name":"Sarah"},{"name":"Clemens","mother":"/0"}]
+     * </pre>
+     * That means instead of serialising 'mother' as full object we will
+     * now only store a JsonPointer to the Person 'Sarah'.
+     *
+     * When deserialised back Johnzon will automatically de-reference the 
JsonPointer
+     * back to the correct instance.
      */
     public MapperBuilder setDeduplicateObjects(boolean deduplicateObjects) {
         this.deduplicateObjects = deduplicateObjects;

Reply via email to