# Record keys to array

**URL:** <https://community.dynatrace.com/t/record-keys-to-array/40655>\
**Category:** DQL\
**Tags:** dql, notebooks\
**Created:** [July 12, 2023, 11:39am UTC](https://community.dynatrace.com/t/record-keys-to-array/40655 "2023-07-12T11:39:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![michael\_altenhu](https://avatars.discourse-cdn.com/v4/letter/m/3da27b/32.png) [@michael\_altenhu](https://community.dynatrace.com/u/michael_altenhu)\
**Post date:** [July 12, 2023, 11:39am UTC](https://community.dynatrace.com/t/record-keys-to-array/40655/1 "2023-07-12T11:39:05Z")

</div>

I use the `parse` command with KVP like this

```code-block
data record(str = "name=\"john\"; age=33; city=\"Atlanta\"")
| parse str, "KVP{LD:key'='(LONG:valueLong | STRING:valueStr)'; '?}:person"

```

so the output will look like this

```auto
"records": [
  {
    "str": "name=\"john\"; age=33; city=\"Atlanta\"",
    "person": {
      "name": "john",
      "age": "33",
      "city": "Atlanta"
    }
  }
]

```

I would like to have only the keys of the _person_ object, so I end up with a structure like this:

```auto
"records": [
  {
    "str": "name=\"john\"; age=33; city=\"Atlanta\"",
    "keys": ["name", "age", "city"]
  }
]

```

So what the Python expression list(person.keys()) would do.

---

<div class="post-metadata">

**Author:** ![sinisa\_zubic](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/sinisa_zubic/32/32498_2.png) [@sinisa\_zubic](https://community.dynatrace.com/u/sinisa_zubic)\
**Post date:** [July 12, 2023, 1:52pm UTC](https://community.dynatrace.com/t/record-keys-to-array/40655/2 "2023-07-12T13:52:41Z")

</div>

Hi&nbsp;[@michael\_altenhu](https://community.dynatrace.com/user/34141)

You could use the array matcher to just extract the keys

```markup
data record(str = "name=\"john\"; age=33; city=\"Atlanta\"")
| parse str, """ARRAY{LD:i '=' LD (';'|' '|EOS)}{1,}:keys"""

```

and this would be the result

```markup
"records": [
    {
      "str": "name=\"john\"; age=33; city=\"Atlanta\"",
      "keys": [
        "name",
        " age",
        " city"
      ]
    }

```

Best,  
Sini
