{"id":25986,"date":"2024-01-28T22:09:34","date_gmt":"2024-01-28T13:09:34","guid":{"rendered":"https:\/\/docs.c-bot.pro\/?p=25986"},"modified":"2024-04-04T17:36:07","modified_gmt":"2024-04-04T08:36:07","slug":"jsonpath","status":"publish","type":"post","link":"https:\/\/docs.c-bot.pro\/en\/user_guide\/bot\/b-bot_editer\/extension\/utility\/jsonpath\/","title":{"rendered":"Utilities \/\u00a0JSONPath"},"content":{"rendered":"\n<p><a href=\"https:\/\/docs.c-bot.pro\/en\/\"><i class=\"fas fa-book\"> <\/i> &nbsp; Home<\/a> &gt; <a href=\"https:\/\/docs.c-bot.pro\/en\/user_guide\">User guide<\/a> &gt; <a href=\"https:\/\/docs.c-bot.pro\/en\/user_guide\/bot\/\">BOT<\/a> &gt; <a href=\"https:\/\/docs.c-bot.pro\/en\/user_guide\/bot\/b-bot_editer\/\">How to use the BOT editor<\/a> &gt; <a href=\"https:\/\/docs.c-bot.pro\/en\/user_guide\/bot\/b-bot_editer\/extension\">Extention<\/a>&gt; <a href=\"https:\/\/docs.c-bot.pro\/en\/user_guide\/bot\/b-bot_editer\/extension\/utility\/\">Utilities<\/a> &gt;  JSONPath<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized extension_icon\" id=\"block-d7d8a08d-ba73-46b3-b534-28587533d10e\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/docs.c-bot.pro\/wp-content\/uploads\/2023\/09\/icon_96p_utility.png\" alt=\"\" class=\"wp-image-24027\" width=\"75\" height=\"75\"><\/figure>\n\n\n\n<h2 id=\"outline__1\" class=\"wp-block-heading\">App overview<\/h2>\n\n\n\n<p>Filter JSON data using JSONPath.<\/p>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>Extended Feature URL<\/td><td>cbot-extension:\/\/cloud-bot:utils:json-path:1<\/td><\/tr><tr><td>Provider<\/td><td>Cloud BOT <span style=\"margin-left: 2px ; padding: 2px 7px; border:0px solid #000 ; background-color: #007bff ; border-radius: 5px ; color: #ffffff ; font-size: 0.7em;\" class=\"badge\">official<\/span><\/td><\/tr><tr><td>External communication<\/td><td>No<\/td><\/tr><tr><td>Version<\/td><td>1<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 id=\"outline__2\" class=\"wp-block-heading\">Screen description<\/h2>\n\n\n\n<h3 id=\"outline__2_1\" class=\"wp-block-heading\">Input screen<\/h3>\n\n\n\n<h4 id=\"outline__2_1_1\" class=\"wp-block-heading\"><strong>Execution option<\/strong><\/h4>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1679\" height=\"1112\" src=\"https:\/\/docs.c-bot.pro\/wp-content\/uploads\/2024\/01\/user_guide_ex_jasonpath_en_01.png\" alt=\"\" class=\"wp-image-26031\"\/><\/figure>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p><strong><strong>JSON data<\/strong><\/strong><\/p>\n\n\n\n<p class=\"extension_detail_item_body\">Specify the target JSON data and the JSONPath to be executed. Increase or decrease the number of JSONPaths by clicking the \"Add\" and \"Delete\" buttons.<\/p>\n\n\n\n<p class=\"extension_detail_item_body has-small-font-size\">* For instructions on how to write JSONPath, refer <a href=\"#outline__3\" data-type=\"internal\" data-id=\"#outline__3\">here<\/a>.<\/p>\n\n\n\n<p><strong><strong><strong>Output format<\/strong><\/strong><\/strong><\/p>\n\n\n\n<p class=\"extension_detail_item_body\">Specifies the output format of the execution results.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>JSON:Display JSON data.<\/li>\n\n\n\n<li>List:Displays the elements of an Array as individual rows.<\/li>\n\n\n\n<li>Table:Displays an \"Array of Objects\" or \"Array of Arrays\" in tabular form. Each element is expanded into rows and object keys into columns.<\/li>\n<\/ul>\n\n\n\n<p class=\"extension_detail_item_body has-small-font-size\">* For details on the output format, refer <a href=\"#outline__2_3\" data-type=\"internal\" data-id=\"#outline__2_3\">here<\/a>.<\/p>\n\n\n\n<p><\/p>\n<\/div>\n<\/div>\n\n\n\n<h3 id=\"outline__2_2\" class=\"wp-block-heading\"><strong>Result screen<\/strong><\/h3>\n\n\n\n<h4 id=\"outline__2_2_1\" class=\"wp-block-heading\">Execution result<\/h4>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1679\" height=\"903\" src=\"https:\/\/docs.c-bot.pro\/wp-content\/uploads\/2024\/01\/user_guide_ex_jasonpath_en_02.png\" alt=\"\" class=\"wp-image-26032\"\/><\/figure>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p>The result of the request made on the input screen will be displayed.<\/p>\n<\/div>\n<\/div>\n\n\n\n<h3 id=\"outline__2_3\" class=\"wp-block-heading\">Additional explanation of \"Output format\"<\/h3>\n\n\n\n<p>The output format can be displayed on the results screen as \"JSON\", \"List\", \"Table\".<\/p>\n\n\n\n<p><strong>JSON<\/strong><br>Display JSON data.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1679\" height=\"595\" src=\"https:\/\/docs.c-bot.pro\/wp-content\/uploads\/2024\/01\/user_guide_ex_jasonpath_en_03-1.png\" alt=\"\" class=\"wp-image-26056\"\/><\/figure>\n\n\n\n<p><strong>List<\/strong><br>Displays the elements of an Array as individual rows. It can be retrieved as group data.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1679\" height=\"595\" src=\"https:\/\/docs.c-bot.pro\/wp-content\/uploads\/2024\/01\/user_guide_ex_jasonpath_en_04.png\" alt=\"\" class=\"wp-image-26034\"\/><\/figure>\n\n\n\n<p><strong>Table<\/strong><br>\"Array of Objects\" or \"Array of Arrays\" in tabular form. Each element is expanded into rows and object keys into columns. It can be retrieved as group data.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1679\" height=\"595\" src=\"https:\/\/docs.c-bot.pro\/wp-content\/uploads\/2024\/01\/user_guide_ex_jasonpath_en_05.png\" alt=\"\" class=\"wp-image-26035\"\/><\/figure>\n\n\n\n<h2 id=\"outline__3\" class=\"wp-block-heading\">About JSONPath<\/h2>\n\n\n\n<h3 id=\"outline__3_1\" class=\"wp-block-heading\">Usage specific samples<\/h3>\n\n\n\n<p>The following JSON data example is used as a sample.<\/p>\n\n\n\n<pre><code>{\n  \"output\": [\n    {\n      \"itemName\": \"CheeseCake\",\n      \"price\": \"500\",\n      \"tags\": [\"Cake\", \"Cheese\"]\n    },\n    {\n      \"itemName\": \"GateauChocolat\",\n      \"price\": \"600\",\n      \"tags\": [\"Cake\", \"Chocolate\"]\n    },\n    {\n      \"itemName\": \"MatchaCake\",\n      \"price\": \"700\",\n      \"tags\": [\"Cake\", \"Matcha\"]\n    }\n  ]\n}\n<\/code><\/pre>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><small><strong>Usage<\/strong><\/small><\/td><td><small><strong>JSONPath(Dot Notation)<\/strong><\/small><\/td><td><small><strong>\nJSONPath(Bracket Notation)<\/strong><\/small><\/td><td><small><strong>\nResult example (Output format: JSON)<\/strong><\/small><\/td><td><small><strong>Remarks<\/strong><\/small><\/td><\/tr><tr><td><small>Obtain the entire JSON data object.<\/small><\/td><td>$<\/td><td>$<\/td><td><small>{ \"output\": [ { \"itemName\": \"CheeseCake\", \"price\": \"500\", \"tags\": [\"Cake\", \"Cheese\"] }, { \"itemName\": \"GateauChocolat\", \"price\": \"600\", \"tags\": [\"Cake\", \"Chocolate\"] }, { \"itemName\": \"MatchaCake\",\"price\": \"700\", \"tags\": [\"Cake\", \"Matcha\"] } ] }<\/small><\/td><td><small>The '$' refers to the top-level object (root element) of the JSON data.<\/small><\/td><\/tr><tr><td><small>Obtain output in a JSON data object.<\/small><\/td><td>$.output<\/td><td>$[\"output\"]<\/td><td><small>\"output\": [ { \"itemName\": \"CheeseCake\", \"price\": \"500\", \"tags\": [\"Cake\", \"Cheese\"] }, { \"itemName\": \"GateauChocolat\", \"price\": \"600\",\"tags\": [\"Cake\", \"Chocolate\"] }, { \"itemName\": \"MatchaCake\", \"price\": \"700\", \"tags\": [\"Cake\", \"Matcha\"] } ]<\/small><\/td><td><\/td><\/tr><tr><td><small>Obtain all elements contained in the output in a JSON data object.<\/small><\/td><td>$.output.*<\/td><td>$[\"output\"][*]<\/td><td><small>[{\"itemName\":\"CheeseCake\",\"price\":\"500\",\"tags\":[\"Cake\",\"Cheese\"]} ,{\"itemName\":\"GateauChocolat\",\"price\":\"600\",\"tags\":[\"Cake\",\"Chocolate\"]},{\"itemName\":\"MatchaCake\",\"price\":\"700\",\"tags\":[\"Cake\",\"Matcha\"]}]<\/small><\/td><td><small>Specify an index for '*' to retrieve a specific element.<br>Example)$.output.0 or $[\"output\"][0]<\/small><\/td><\/tr><tr><td><small>\nObtain the price of each element contained in the output in the JSON data object.<\/small><\/td><td>$.output.*.price<\/td><td>$[\"output\"][*][\"price\"]<\/td><td><small>[\"500\",\"600\",\"700\"]<\/small><\/td><td><small>Obtain multiple elements by separating them with ','.<br>Example)$.output[0][\"price\",\"tags\"] or $[\"output\"][0][\"price\",\"tags\"]<\/small><\/td><\/tr><tr><td><small>Obtain all prices of any hierarchy from the entire JSON data.<\/small><\/td><td>$..price<\/td><td>-<\/td><td><small>[\"500\",\"600\",\"700\"]<\/small><\/td><td><small>Use '..' to filter through all levels and obtain all values matching the key.<\/small><\/td><\/tr>\n<tr><td><small>Obtains the first (0th) and 2nd elements of output in a JSON data object.<\/small><\/td><td>-<\/td><td>$.output[0,2]<\/td><td><small>[{\"itemName\":\"CheeseCake\",\"price\":\"500\",\"tags\":[\"Cake\",\"Cheese\"]} ,{\"itemName\":\"MatchaCake\",\"price\":\"700\",\"tags\":[\"Cake\",\"Matcha\"]}]<\/small><\/td><td><\/td><\/tr>\n<tr><td><small>Obtains a range of consecutive elements from the first (0th) element in the output in the JSON data object.<\/small><\/td><td>-<\/td><td>$.output[0:2]<\/td><td><small>[{\"itemName\":\"CheeseCake\",\"price\":\"500\",\"tags\":[\"Cake\",\"Cheese\"]} ,{\"itemName\":\"GateauChocolat\",\"price\":\"600\",\"tags\":[\"Cake\",\"Chocolate\"]}]<\/small><\/td><td><small>A range of consecutive elements in an array can be specified in the format [ &lt; start &gt; : &lt; end &gt; ]. The &lt; start &gt; indicates the start index of the range (inclusive) and the &lt; end &gt; indicates the end index (exclusive). For example, if you specify [0:2], you will get from the 0th element to the element immediately before the 2nd element (the 1st element).<\/small><\/td><\/tr>\n<tr><td><small>Obtains the element whose itemName value is equal to CheeseCake in the output in the JSON data object.<\/small><\/td><td>$.output[?(@.itemName == 'CheeseCake')]<\/td><td>$.output[?(@[\"itemName\"] == [\"CheeseCake\"])]<\/td><td><small>[{\"itemName\":\"CheeseCake\",\"price\":\"500\",\"tags\":[\"Cake\",\"Cheese\"]}]<\/small><\/td><td><small>Use '@' to set conditions for each element within an array and filter to obtain the elements.<\/small><\/td><\/tr>\n<tr><td><small>Obtains the value of itemName and tags contained in the output in the JSON data object whose price value is less than 600.<\/small><\/td><td>-<\/td><td>$.output[?(@[\"price\"] &lt; \"600\")][\"itemName\",\"tags\"]<\/td><td><small>[\"CheeseCake\",[\"Cake\",\"Cheese\"]]<\/small><\/td><td><small>Refer <a href=\"#outline__3_4\">here<\/a> for how to write conditional expressions.<\/small><\/td><\/tr><tr><td><small>Obtain the element contained in the output in the JSON data object whose price value is less than 600 and whose itemName value is equal to CheeseCake.<\/small><\/td><td>$.output[?(@.price &lt;= 600 &amp;&amp; @.itemName == 'CheeseCake')]<\/td><td>$.output[?(@[\"price\"] &lt;= \"600\" &amp;&amp; @[\"itemName\"] == \"CheeseCake\")]<\/td><td><small>[{\"itemName\":\"CheeseCake\",\"price\":\"500\",\"tags\":[\"Cake\",\"Cheese\"]}]<\/small><\/td><td><small>Refer <a href=\"#outline__3_5\">here<\/a> for how to combine multiple conditions.<\/small><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 id=\"outline__3_2\" class=\"wp-block-heading\">Dot Notation<\/h3>\n\n\n\n<p><strong>.key<\/strong> or <strong>\"key\"<\/strong>(<strong>'key'<\/strong>)<\/p>\n\n\n\n<p>Dot notation is suitable for key names that start with an alphabet character and do not include spaces or special characters. It intuitively indicates the hierarchical structure.<\/p>\n\n\n\n<h3 id=\"outline__3_3\" class=\"wp-block-heading\">Bracket Notation<\/h3>\n\n\n\n<p><strong>['key']<\/strong> or <strong>[\"key\"]<\/strong><\/p>\n\n\n\n<p>Bracket notation is used when key names include spaces, hyphens, Japanese or other multibyte (full-width) characters, special characters, or when key names start with a number, situations where dot notation is not applicable. It allows for specifying any key name.<\/p>\n\n\n\n<h3 id=\"outline__3_4\" class=\"wp-block-heading\">Conditional Expressions<\/h3>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1679\" height=\"126\" src=\"https:\/\/docs.c-bot.pro\/wp-content\/uploads\/2024\/01\/user_guide_ex_jasonpath_en_07.png\" alt=\"\" class=\"wp-image-26037\"\/><\/figure>\n\n\n\n<p>Conditional expressions are used to compare two values. Elements that meet certain conditions are retrieved or excluded.<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>Comparison Operators<\/strong><\/td><td><strong>Meaning<\/strong><\/td><\/tr><tr><td>==<\/td><td>is equal to (the left side is the same as the right side)<\/td><\/tr><tr><td>!=<\/td><td>is not equal to (the left side is different from the right side)<\/td><\/tr><tr><td>&lt;<\/td><td>is less than (the left side is smaller than the right side)<\/td><\/tr><tr><td>&gt;<\/td><td>is greater than (the left side is larger than the right side)<\/td><\/tr><tr><td>&lt;=<\/td><td>is less than or equal to (the left side is smaller than or equal to the right side)<\/td><\/tr><tr><td>&gt;=<\/td><td>is greater than or equal to (the left side is larger than or equal to the right side)<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 id=\"outline__3_5\" class=\"wp-block-heading\">Multiple Conditions<\/h3>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1679\" height=\"149\" src=\"https:\/\/docs.c-bot.pro\/wp-content\/uploads\/2024\/01\/user_guide_ex_jasonpath_en_08-1.png\" alt=\"\" class=\"wp-image-26052\"\/><\/figure>\n\n\n\n<p>Multiple conditions combine two conditional expressions.<br>Complex conditions or specific definitions determine how the overall result is handled.<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>Logical Operators<\/strong><\/td><td><strong>Meaning<\/strong><\/td><\/tr><tr><td>&amp;&amp;<\/td><td>true if both conditions are met(AND)<\/td><\/tr><tr><td>||<\/td><td>true if at least one of the conditions is met(OR)<\/td><\/tr><\/tbody><\/table><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; Home &gt; User guide &gt; BOT &gt; How to use the BOT editor &gt; Extention&gt; Utilities &gt; JSONPath App overview Filter JSON data using JSONPath. Extended Feature URL cbot-extension:\/\/cloud-bot:utils:json-path:1 Provider Cloud BOT official External communication No Version 1 Screen description Input screen Execution option JSON data Specify the target JSON data and the JSONPath to be executed. Increase or decrease the number of JSONPaths by clicking the \"Add\" and \"Delete\" buttons. * For instructions on how to write JSONPath, refer here. Output format Specifies the output format of the execution results. * For details on the output format, refer here. Result screen Execution result The result of the request made on the input screen will be displayed. Additional explanation of \"Output format\" The output format can be displayed on the results screen as \"JSON\", \"List\", \"Table\". JSONDisplay JSON data. ListDisplays the elements of an Array as individual rows. It can be retrieved as group data. Table\"Array of Objects\" or \"Array of Arrays\" in tabular form. Each element is expanded into rows and object keys into columns. It can be retrieved as group data. About JSONPath Usage specific samples The following JSON data example is used as a sample. { [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_locale":"en_US","_original_post":"https:\/\/docs.c-bot.pro\/?p=25956","footnotes":""},"categories":[63],"tags":[110,109,107],"class_list":["post-25986","post","type-post","status-publish","format-standard","hentry","category-utility","tag-bot-editor","tag-extention","tag-jsonpath","en-US"],"_links":{"self":[{"href":"https:\/\/docs.c-bot.pro\/wp-json\/wp\/v2\/posts\/25986","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/docs.c-bot.pro\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.c-bot.pro\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.c-bot.pro\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.c-bot.pro\/wp-json\/wp\/v2\/comments?post=25986"}],"version-history":[{"count":10,"href":"https:\/\/docs.c-bot.pro\/wp-json\/wp\/v2\/posts\/25986\/revisions"}],"predecessor-version":[{"id":27835,"href":"https:\/\/docs.c-bot.pro\/wp-json\/wp\/v2\/posts\/25986\/revisions\/27835"}],"wp:attachment":[{"href":"https:\/\/docs.c-bot.pro\/wp-json\/wp\/v2\/media?parent=25986"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.c-bot.pro\/wp-json\/wp\/v2\/categories?post=25986"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.c-bot.pro\/wp-json\/wp\/v2\/tags?post=25986"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}