1
+ /*
2
+ * Copyright (c) 2014, Francis Galiegue (fgaliegue@gmail.com)
3
+ *
4
+ * This software is dual-licensed under:
5
+ *
6
+ * - the Lesser General Public License (LGPL) version 3.0 or, at your option, any
7
+ * later version;
8
+ * - the Apache Software License (ASL) version 2.0.
9
+ *
10
+ * The text of this file and of both licenses is available at the root of this
11
+ * project or, if you have the jar distribution, in directory META-INF/, under
12
+ * the names LGPL-3.0.txt and ASL-2.0.txt respectively.
13
+ *
14
+ * Direct link to the sources:
15
+ *
16
+ * - LGPL 3.0: https://www.gnu.org/licenses/lgpl-3.0.txt
17
+ * - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
18
+ */
19
+
20
+ /**
21
+ * JSON Merge Patch implementation
22
+ *
23
+ * <p>This is a complete implementation of <a
24
+ * href="http://tools.ietf.org/html/rfc7386>RFC 7386 (JSON Merge Patch)</a>.</p>
25
+ *
26
+ * <p>You may want to use this instead of a "pure" (aka RFC 6902) JSON Patch if
27
+ * you want to do simple patching of JSON Objects, where this implementation
28
+ * really shines. For instance, if you want to replace a value for one
29
+ * property {@code p} with JSON String {@code "bar"}, a JSON Patch will read:
30
+ * </p>
31
+ *
32
+ * <pre>
33
+ * [
34
+ * { "op": "replace", "path": "/p", "value": "bar" }
35
+ * ]
36
+ * </pre>
37
+ *
38
+ * <p>whereas the equivalent JSON Merge Patch will be:</p>
39
+ *
40
+ * <pre>
41
+ * { "p": "bar"}
42
+ * </pre>
43
+ *
44
+ * <p>Note that this is recursive; therefore, this:</p>
45
+ *
46
+ * <pre>
47
+ * { "a": { "b": "c" } }
48
+ * </pre>
49
+ *
50
+ * <p>will replace (or add, if not present) the value at JSON Pointer {@code
51
+ * /a/b} with JSON String {@code "c"}.</p>
52
+ *
53
+ * <p><b>HOWEVER:</b> while this seems attractive, there are a few traps. One
54
+ * of them is that, when a value of an object member in a JSON Merge Patch is
55
+ * a JSON null, the target will see the equivalent member <b>removed</b>; there
56
+ * is no way to specify that a value should be set with a JSON null value (JSON
57
+ * Patch allows for this).</p>
58
+ *
59
+ * <p>The RFC defines a pseudo code for how a JSON Merge Patch is applied; this
60
+ * function is replicated in the javadoc for {@link
61
+ * com.github.fge.jsonpatch.mergepatch.JsonMergePatch}, so you are encouraged to
62
+ * read the javadoc for this class, and the RFC itself.</p>
63
+ */
64
+ package com .github .fge .jsonpatch .mergepatch ;
0 commit comments