Skip to content

Commit

Permalink
json.patch: update docs to include behavior with sets
Browse files Browse the repository at this point in the history
Fixes #5328

Signed-off-by: Anders Eknert <anders@eknert.com>
  • Loading branch information
anderseknert committed Nov 29, 2022
1 parent 7540f11 commit 95cacad
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion ast/builtins.go
Expand Up @@ -1477,7 +1477,9 @@ var JSONRemove = &Builtin{
var JSONPatch = &Builtin{
Name: "json.patch",
Description: "Patches an object according to RFC6902. " +
"For example: `json.patch({\"a\": {\"foo\": 1}}, [{\"op\": \"add\", \"path\": \"/a/bar\", \"value\": 2}])` results in `{\"a\": {\"foo\": 1, \"bar\": 2}`. The patches are applied atomically: if any of them fails, the result will be undefined.",
"For example: `json.patch({\"a\": {\"foo\": 1}}, [{\"op\": \"add\", \"path\": \"/a/bar\", \"value\": 2}])` results in `{\"a\": {\"foo\": 1, \"bar\": 2}`. " +
"The patches are applied atomically: if any of them fails, the result will be undefined. " +
"Additionally works on sets, where a value contained in the set is considered to be its path.",
Decl: types.NewFunction(
types.Args(
types.Named("object", types.A), // TODO(sr): types.A?
Expand Down
2 changes: 1 addition & 1 deletion builtin_metadata.json
Expand Up @@ -7568,7 +7568,7 @@
"v0.46.1",
"edge"
],
"description": "Patches an object according to RFC6902. For example: `json.patch({\"a\": {\"foo\": 1}}, [{\"op\": \"add\", \"path\": \"/a/bar\", \"value\": 2}])` results in `{\"a\": {\"foo\": 1, \"bar\": 2}`. The patches are applied atomically: if any of them fails, the result will be undefined.",
"description": "Patches an object according to RFC6902. For example: `json.patch({\"a\": {\"foo\": 1}}, [{\"op\": \"add\", \"path\": \"/a/bar\", \"value\": 2}])` results in `{\"a\": {\"foo\": 1, \"bar\": 2}`. The patches are applied atomically: if any of them fails, the result will be undefined. Additionally works on sets, where a value contained in the set is considered to be its path.",
"introduced": "v0.25.0",
"result": {
"description": "result obtained after consecutively applying all patch operations in `patches`",
Expand Down

0 comments on commit 95cacad

Please sign in to comment.