{"id":90,"date":"2018-12-07T14:06:00","date_gmt":"2018-12-07T14:06:00","guid":{"rendered":"https:\/\/www.json-buddy.com\/blog\/?p=90"},"modified":"2022-10-18T14:13:36","modified_gmt":"2022-10-18T14:13:36","slug":"full-jsonpatch-support-in-jsonbuddy","status":"publish","type":"post","link":"https:\/\/www.json-buddy.com\/blog\/2018\/12\/07\/full-jsonpatch-support-in-jsonbuddy\/","title":{"rendered":"Full JSONPatch support in JSONBuddy"},"content":{"rendered":"<p>JSONPatch allows modifying JSON data with a set of operations defined itself as a JSON array. <a href=\"https:\/\/www.json-buddy.com\" target=\"_blank\" rel=\"noopener\">JSONBuddy<\/a> 5.1 supports the complete JSONPatch specification <strong>directly in the editor<\/strong> to apply any number of operations to any number of JSON documents.<\/p>\n\n\n<p>Just a few details to get an idea what JSONPatch can do for you. A simple JSONPatch operation could look like the following example:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[ { \"op\": \"copy\", \"from\": \"\/baz\/0\", \"path\": \"\/boo\" } ]<\/pre>\n\n\n\n<p>In words, this operation copies the value from the JSONPointer &#8220;\/baz\/0&#8221; to the location at the JSONPointer &#8220;\/boo&#8221;. So applied to the following JSON input:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">{<br>  \"baz\": [ { \"qux\": \"hello\" } ],<br>  \"bar\": 1<br>}<\/pre>\n\n\n\n<p>You get the following JSON as result:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">{<br>    \"baz\": [ { \"qux\": \"hello\" } ],<br>    \"bar\": 1,<br>    \"boo\": { \"qux\": \"hello\" }<br>}<\/pre>\n\n\n\n<p>As you can see, the value from the first item of &#8220;baz&#8221; array is copied to the root as a new value named &#8220;boo&#8221;. It doesn&#8217;t matter, that the &#8220;boo&#8221; property didn&#8217;t exist beforehand.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/www.json-buddy.com\/blog\/wp-content\/uploads\/2018\/12\/apply-jsonpatch-file-explorer.png\" alt=\"\" class=\"wp-image-268\"\/><figcaption>Apply JSONPatch operations from the built-in File Explorer.<\/figcaption><\/figure><\/div>\n\n\n<p>If you want to apply JSONPatch operations to one or more JSON data documents, select the files in the built-in File explorer first. Then use the context menu to get a standard file dialog to select the JSON with the array of JSONPatch operations.<\/p>\n\n\n\n<h2>Apply the JSONPatch operations to the active document<\/h2>\n\n\n\n<p>If you want to modify the current JSON document in the editor using JSONPatch operations, set the focus to the document and use the &#8220;JSON | Apply JSONPatch operations&#8230;&#8221; command from the main menu bar. This will also open a standard file dialog where you can select the JSONPatch operations to apply.<\/p>\n\n\n\n<h2>Use JSONPatch from the command-line tool<\/h2>\n\n\n\n<p>In addition, the latest <strong>command-line tool<\/strong> has also support for JSONPatch. Simply use the &#8220;patch&#8221; option to apply a set of JSONPatch operations to any number of JSON data files:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">valbuddy.exe -patch \"D:\\Documents\\JSON\\JSONPatch-Test-Suite\\simple-patch.json\" \"D:\\Documents\\JSON\\JSONPatch-Test-Suite\\simple-instance.json\"<\/pre>\n\n\n\n<p>Where the first parameter after the &#8220;patch&#8221; switch is always taken as the JSON input with the array of JSONPatch operations. All following parameters are taken as paths to JSON documents to apply the modifications.<\/p>\n\n\n\n<p>As usual, you find the &#8220;valbuddy.exe&#8221; command-line tool in the installation folder of the JSONBuddy editor software package.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>JSONPatch allows modifying JSON data with a set of operations defined itself as a JSON array. JSONBuddy 5.1 supports the complete JSONPatch specification directly in the editor to apply any number of operations to any number of JSON documents. Just a few details to get an idea what JSONPatch can do for you. A simple &hellip; <a href=\"https:\/\/www.json-buddy.com\/blog\/2018\/12\/07\/full-jsonpatch-support-in-jsonbuddy\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Full JSONPatch support in JSONBuddy<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[17],"tags":[23],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.json-buddy.com\/blog\/wp-json\/wp\/v2\/posts\/90"}],"collection":[{"href":"https:\/\/www.json-buddy.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.json-buddy.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.json-buddy.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.json-buddy.com\/blog\/wp-json\/wp\/v2\/comments?post=90"}],"version-history":[{"count":3,"href":"https:\/\/www.json-buddy.com\/blog\/wp-json\/wp\/v2\/posts\/90\/revisions"}],"predecessor-version":[{"id":93,"href":"https:\/\/www.json-buddy.com\/blog\/wp-json\/wp\/v2\/posts\/90\/revisions\/93"}],"wp:attachment":[{"href":"https:\/\/www.json-buddy.com\/blog\/wp-json\/wp\/v2\/media?parent=90"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.json-buddy.com\/blog\/wp-json\/wp\/v2\/categories?post=90"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.json-buddy.com\/blog\/wp-json\/wp\/v2\/tags?post=90"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}