{"id":3424,"date":"2022-11-15T13:34:38","date_gmt":"2022-11-15T13:34:38","guid":{"rendered":"https:\/\/info.documotor.com\/?page_id=3424"},"modified":"2023-01-25T10:17:59","modified_gmt":"2023-01-25T10:17:59","slug":"has_value","status":"publish","type":"page","link":"https:\/\/info.documotor.com\/?page_id=3424","title":{"rendered":"Has_value"},"content":{"rendered":"\n<p>This function can be used to evaluate if data $entry has a <a href=\"https:\/\/info.documotor.com\/?page_id=644\">truthy value<\/a>.<\/p>\n\n\n\n<h3>Syntax<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">bool has_value(any $entry)<\/code><\/pre>\n\n\n\n<p>This function will output &#8220;true&#8221; or &#8220;false&#8221; based on evaluation of $entry.<\/p>\n\n\n\n<h3>Parameters<\/h3>\n\n\n\n<p><strong>$entry: <\/strong>The data to evaluate. <\/p>\n\n\n\n<p>The following values are not truthy:<\/p>\n\n\n\n<ul><li>Null<\/li><li>\u201c\u201d<\/li><li>\u201cfalse\u201d<\/li><li>\u201cnull\u201d<\/li><li>false<\/li><li>0<\/li><\/ul>\n\n\n\n<p>In case the JSON path leads to an array, the array is not truthy if the array has 0 or \u2018null\u2019 elements.<\/p>\n\n\n\n<h3>Example<\/h3>\n\n\n\n<p>In this example, two values are evaluated. One results in a truthy, while the other does not.<\/p>\n\n\n\n<pre title=\"Data\" class=\"wp-block-code\"><code lang=\"json\" class=\"language-json line-numbers\">{\n    \"Data1\": [\"a\", \"b\", \"c\"],\n    \"Data2\": null\n}<\/code><\/pre>\n\n\n\n<pre title=\"Transformation\" class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash line-numbers\">{\n    First: has_value(Data1),\n    Second: has_value(Data2)\n}<\/code><\/pre>\n\n\n\n<pre title=\"Output\" class=\"wp-block-code\"><code lang=\"json\" class=\"language-json line-numbers\">{\n    \"First\": true,\n    \"Second\": false\n}<\/code><\/pre>\n\n\n\n<p>&#8220;First&#8221; results in <code>true<\/code> because &#8220;Data1&#8221; contains values in it&#8217;s array. &#8220;Second&#8221; results in <code>false<\/code> because it does not have a truthy value as according to the bulleted list above.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This function can be used to evaluate if data $entry has a truthy value. Syntax This function will output &#8220;true&#8221; or &#8220;false&#8221; based on evaluation of $entry. Parameters $entry: The data to evaluate. The following values are not truthy: Null \u201c\u201d \u201cfalse\u201d \u201cnull\u201d false 0 In case the JSON path leads to an array, the [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"parent":271,"menu_order":71,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/info.documotor.com\/index.php?rest_route=\/wp\/v2\/pages\/3424"}],"collection":[{"href":"https:\/\/info.documotor.com\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/info.documotor.com\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/info.documotor.com\/index.php?rest_route=\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/info.documotor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3424"}],"version-history":[{"count":5,"href":"https:\/\/info.documotor.com\/index.php?rest_route=\/wp\/v2\/pages\/3424\/revisions"}],"predecessor-version":[{"id":3768,"href":"https:\/\/info.documotor.com\/index.php?rest_route=\/wp\/v2\/pages\/3424\/revisions\/3768"}],"up":[{"embeddable":true,"href":"https:\/\/info.documotor.com\/index.php?rest_route=\/wp\/v2\/pages\/271"}],"wp:attachment":[{"href":"https:\/\/info.documotor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3424"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}