Created
July 9, 2014 17:16
-
-
Save briancavalier/7f2f90b9d5efb56e86a5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// JSON Patch containing a splice operation with context | |
[{ | |
"op": "splice", | |
"path": "/3", | |
"+": ["d", "e"], | |
"-": ["x", "y", "z"], | |
"<": ["a", "b", "c"], | |
">": ["f", "g"] | |
}] | |
// Applied to this array: | |
["extra", "a", "b", "c", "x", "y", "z", "f", "g"] | |
// Yields: | |
["extra", "a", "b", "c", "d", "e", "f", "g"] | |
// Inverting a splice, simply swap + and - | |
[{ | |
"op": "splice", | |
"path": "/3", | |
"+": ["x", "y", "z"], | |
"-": ["d", "e"], | |
"<": ["a", "b", "c"], | |
">": ["f", "g"] | |
}] | |
// Applied to the previous result: | |
["extra", "a", "b", "c", "d", "e", "f", "g"] | |
// Yields the original: | |
["extra", "a", "b", "c", "x", "y", "z", "f", "g"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment