{"id":54,"date":"2018-06-22T10:04:00","date_gmt":"2018-06-22T10:04:00","guid":{"rendered":"https:\/\/www.json-buddy.com\/blog\/?p=54"},"modified":"2022-10-10T10:08:08","modified_gmt":"2022-10-10T10:08:08","slug":"json-code-folding","status":"publish","type":"post","link":"https:\/\/www.json-buddy.com\/blog\/2018\/06\/22\/json-code-folding\/","title":{"rendered":"Tales from support: JSON code folding"},"content":{"rendered":"\n<p>Someone who set &#8220;Recommend: yes&#8221; and &#8220;Overall quality: 1&#8221; (best) on the survey form sent the additional following feedback:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>Code folding for JSON file does not work for situations like: &#8220;RaceCar&#8221;: { &#8220;Domestic&#8221;: true, &#8220;Model&#8221;: [] }<\/p><\/blockquote>\n\n\n\n<p>Unfortunately, the user did not provide an email address so I couldn&#8217;t get in contact with her\/him. So what is the <strong><a href=\"https:\/\/www.json-buddy.com\" target=\"_blank\" rel=\"noopener\">JSON editor<\/a><\/strong> doing with JSON data like this in terms of code folding? The sample data is all in one line. There is actually no chance for the editor to show code folding for JSON content that spans over a single line.<\/p>\n\n\n\n<h2>Use JSON pretty-print to show code folding<\/h2>\n\n\n\n<p>However, if you are using JSONBuddy as your JSON editor you also get a very <strong>useful pretty-print<\/strong> functionality that can be quickly executed by just pressing Ctrl-Shift-P. The sample JSON is immediately formatted in the following way:<\/p>\n\n\n\n<figure class=\"wp-block-image alignnone size-full wp-image-141\"><img decoding=\"async\" src=\"https:\/\/www.json-buddy.com\/blog\/wp-content\/uploads\/2018\/06\/json-pretty-print-simple.png\" alt=\"Formatting JSON with pretty-print in JSONBuddy\" class=\"wp-image-141\"\/><figcaption>Formatting JSON with pretty-print in JSONBuddy<\/figcaption><\/figure>\n\n\n\n<p>As you can see, folding is available after the JSON data is formatted in the editor. It is also convenient that the current selection is also preserved after the pretty-print operation is completed. Maybe a small but important detail to provide the best JSON editor experience possible.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Someone who set &#8220;Recommend: yes&#8221; and &#8220;Overall quality: 1&#8221; (best) on the survey form sent the additional following feedback: Code folding for JSON file does not work for situations like: &#8220;RaceCar&#8221;: { &#8220;Domestic&#8221;: true, &#8220;Model&#8221;: [] } Unfortunately, the user did not provide an email address so I couldn&#8217;t get in contact with her\/him. So &hellip; <a href=\"https:\/\/www.json-buddy.com\/blog\/2018\/06\/22\/json-code-folding\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Tales from support: JSON code folding<\/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":[18,8],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.json-buddy.com\/blog\/wp-json\/wp\/v2\/posts\/54"}],"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=54"}],"version-history":[{"count":2,"href":"https:\/\/www.json-buddy.com\/blog\/wp-json\/wp\/v2\/posts\/54\/revisions"}],"predecessor-version":[{"id":56,"href":"https:\/\/www.json-buddy.com\/blog\/wp-json\/wp\/v2\/posts\/54\/revisions\/56"}],"wp:attachment":[{"href":"https:\/\/www.json-buddy.com\/blog\/wp-json\/wp\/v2\/media?parent=54"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.json-buddy.com\/blog\/wp-json\/wp\/v2\/categories?post=54"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.json-buddy.com\/blog\/wp-json\/wp\/v2\/tags?post=54"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}