<?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 Re: Record keys to array in DQL</title>
    <link>https://community.dynatrace.com/t5/DQL/Record-keys-to-array/m-p/217784#M134</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.dynatrace.com/t5/user/viewprofilepage/user-id/34141"&gt;@michael_altenhu&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could use the array matcher to just extract the keys&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;data record(str = "name=\"john\"; age=33; city=\"Atlanta\"")
| parse str, """ARRAY{LD:i '=' LD (';'|' '|EOS)}{1,}:keys"""&lt;/LI-CODE&gt;
&lt;P&gt;and this would be the result&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;  "records": [
    {
      "str": "name=\"john\"; age=33; city=\"Atlanta\"",
      "keys": [
        "name",
        " age",
        " city"
      ]
    }&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best,&lt;BR /&gt;Sini&lt;/P&gt;</description>
    <pubDate>Wed, 12 Jul 2023 13:52:41 GMT</pubDate>
    <dc:creator>sinisa_zubic</dc:creator>
    <dc:date>2023-07-12T13:52:41Z</dc:date>
    <item>
      <title>Record keys to array</title>
      <link>https://community.dynatrace.com/t5/DQL/Record-keys-to-array/m-p/217727#M133</link>
      <description>&lt;P&gt;I use the `parse` command with KVP like this&lt;/P&gt;
&lt;PRE class="code-block"&gt;&lt;CODE class="hljs"&gt;data record(str = "name=\"john\"; age=33; city=\"Atlanta\"")&lt;BR /&gt;| parse str, "KVP{LD:key'='(LONG:valueLong | STRING:valueStr)'; '?}:person"&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;so the output will look like this&lt;/P&gt;
&lt;PRE&gt;"records": [&lt;BR /&gt;  {&lt;BR /&gt;    "str": "name=\"john\"; age=33; city=\"Atlanta\"",&lt;BR /&gt;    "person": {&lt;BR /&gt;      "name": "john",&lt;BR /&gt;      "age": "33",&lt;BR /&gt;      "city": "Atlanta"&lt;BR /&gt;    }&lt;BR /&gt;  }&lt;BR /&gt;]&lt;/PRE&gt;
&lt;P&gt;I would like to have only the keys of the &lt;EM&gt;person&lt;/EM&gt; object, so I end up with a structure like this:&lt;/P&gt;
&lt;PRE&gt;"records": [&lt;BR /&gt;  {&lt;BR /&gt;    "str": "name=\"john\"; age=33; city=\"Atlanta\"",&lt;BR /&gt;    "keys": [ "name", "age", "city" ]&lt;BR /&gt;&amp;nbsp; }&lt;BR /&gt;]&lt;/PRE&gt;
&lt;P&gt;So what the Python expression &lt;FONT face="andale mono,times"&gt;list(person.keys())&lt;/FONT&gt; would do.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jul 2023 11:39:05 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Record-keys-to-array/m-p/217727#M133</guid>
      <dc:creator>michael_altenhu</dc:creator>
      <dc:date>2023-07-12T11:39:05Z</dc:date>
    </item>
    <item>
      <title>Re: Record keys to array</title>
      <link>https://community.dynatrace.com/t5/DQL/Record-keys-to-array/m-p/217784#M134</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.dynatrace.com/t5/user/viewprofilepage/user-id/34141"&gt;@michael_altenhu&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could use the array matcher to just extract the keys&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;data record(str = "name=\"john\"; age=33; city=\"Atlanta\"")
| parse str, """ARRAY{LD:i '=' LD (';'|' '|EOS)}{1,}:keys"""&lt;/LI-CODE&gt;
&lt;P&gt;and this would be the result&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;  "records": [
    {
      "str": "name=\"john\"; age=33; city=\"Atlanta\"",
      "keys": [
        "name",
        " age",
        " city"
      ]
    }&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best,&lt;BR /&gt;Sini&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jul 2023 13:52:41 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Record-keys-to-array/m-p/217784#M134</guid>
      <dc:creator>sinisa_zubic</dc:creator>
      <dc:date>2023-07-12T13:52:41Z</dc:date>
    </item>
  </channel>
</rss>

