<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic get_json_object and json path filtering in Get Started Discussions</title>
    <link>https://community.databricks.com/t5/get-started-discussions/get-json-object-and-json-path-filtering/m-p/71841#M7425</link>
    <description>&lt;P&gt;I have following string&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;[{"key":"abc","value":{"string_value":"abc123"}},{"key":"def","value":{"int_value":123}},{"key":"ghi","value":{"string_value":"ghi456"}}]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and from that string i need to extract key.value.string_value for key with the value equal to "ghi"&lt;/P&gt;&lt;P&gt;i ran test in the jsonpath(dot)curiousconcept(dot)com and got working path condition to get to such value&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;$[?(@.key == 'ghi')].value.string_value&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;result is: "ghi456" as expected&lt;/P&gt;&lt;P&gt;however when i run this in dbx, i got always null and i am not sure if path filtering works there at all&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;select get_json_object('[{"key":"abc","value":{"string_value":"abc123"}},{"key":"def","value":{"int_value":123}},{"key":"ghi","value":{"string_value":"ghi456"}}]', '$[?(@.key == "ghi")].value.string_value')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Above query always returns null.&lt;/P&gt;&lt;P&gt;Is it DBx implementation of get_json_object and json path within it being not exactly regular json path or do i have to something else to get to the value as in the example?&lt;/P&gt;&lt;P&gt;Thank you a lot for your time and help &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 06 Jun 2024 10:04:08 GMT</pubDate>
    <dc:creator>MadCowTM</dc:creator>
    <dc:date>2024-06-06T10:04:08Z</dc:date>
    <item>
      <title>get_json_object and json path filtering</title>
      <link>https://community.databricks.com/t5/get-started-discussions/get-json-object-and-json-path-filtering/m-p/71841#M7425</link>
      <description>&lt;P&gt;I have following string&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;[{"key":"abc","value":{"string_value":"abc123"}},{"key":"def","value":{"int_value":123}},{"key":"ghi","value":{"string_value":"ghi456"}}]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and from that string i need to extract key.value.string_value for key with the value equal to "ghi"&lt;/P&gt;&lt;P&gt;i ran test in the jsonpath(dot)curiousconcept(dot)com and got working path condition to get to such value&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;$[?(@.key == 'ghi')].value.string_value&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;result is: "ghi456" as expected&lt;/P&gt;&lt;P&gt;however when i run this in dbx, i got always null and i am not sure if path filtering works there at all&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;select get_json_object('[{"key":"abc","value":{"string_value":"abc123"}},{"key":"def","value":{"int_value":123}},{"key":"ghi","value":{"string_value":"ghi456"}}]', '$[?(@.key == "ghi")].value.string_value')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Above query always returns null.&lt;/P&gt;&lt;P&gt;Is it DBx implementation of get_json_object and json path within it being not exactly regular json path or do i have to something else to get to the value as in the example?&lt;/P&gt;&lt;P&gt;Thank you a lot for your time and help &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jun 2024 10:04:08 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/get-json-object-and-json-path-filtering/m-p/71841#M7425</guid>
      <dc:creator>MadCowTM</dc:creator>
      <dc:date>2024-06-06T10:04:08Z</dc:date>
    </item>
    <item>
      <title>Re: get_json_object and json path filtering</title>
      <link>https://community.databricks.com/t5/get-started-discussions/get-json-object-and-json-path-filtering/m-p/72207#M7426</link>
      <description>&lt;P&gt;Can you try with the below code snippet&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;WITH exploded_json AS (
  SELECT explode(from_json(
    '[{"key":"abc","value":{"string_value":"abc123"}},{"key":"def","value":{"int_value":123}},{"key":"ghi","value":{"string_value":"ghi456"}}]', 
    'array&amp;lt;struct&amp;lt;key:string,value:struct&amp;lt;int_value:int,string_value:string&amp;gt;&amp;gt;&amp;gt;'
  )) as json_element
)
SELECT json_element.value.string_value
FROM exploded_json
WHERE json_element.key = 'ghi'&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 10 Jun 2024 08:59:44 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/get-json-object-and-json-path-filtering/m-p/72207#M7426</guid>
      <dc:creator>brickster_2018</dc:creator>
      <dc:date>2024-06-10T08:59:44Z</dc:date>
    </item>
  </channel>
</rss>

