12 Jul 2023 12:39 PM
I use the `parse` command with KVP like this
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
"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:
"records": [
{
"str": "name=\"john\"; age=33; city=\"Atlanta\"",
"keys": [ "name", "age", "city" ]
}
]
So what the Python expression list(person.keys()) would do.
Solved! Go to Solution.
12 Jul 2023 02:52 PM
You could use the array matcher to just extract the keys
data record(str = "name=\"john\"; age=33; city=\"Atlanta\"")
| parse str, """ARRAY{LD:i '=' LD (';'|' '|EOS)}{1,}:keys"""
and this would be the result
"records": [
{
"str": "name=\"john\"; age=33; city=\"Atlanta\"",
"keys": [
"name",
" age",
" city"
]
}
Best,
Sini