🐛 (webhook) Fix deep key parser dropdown
Improve the parsing of response keys
This commit is contained in:
@ -10,10 +10,20 @@ export const getDeepKeys = (obj: any): string[] => {
|
||||
})
|
||||
)
|
||||
} else if (Array.isArray(obj[key])) {
|
||||
if (obj[key].length === 0) continue
|
||||
if (obj[key].length === 1) {
|
||||
const subkeys = getDeepKeys(obj[key][0])
|
||||
keys = keys.concat(
|
||||
subkeys.map(function (subkey) {
|
||||
return `${key}[0]${parseKey(subkey)}`
|
||||
})
|
||||
)
|
||||
continue
|
||||
}
|
||||
const subkeys = getDeepKeys(obj[key][0])
|
||||
keys = keys.concat(
|
||||
subkeys.map(function (subkey) {
|
||||
return `${key}.map(item => item${parseKey(subkey)})`
|
||||
return `${key}.flatMap(item => item${parseKey(subkey)})`
|
||||
})
|
||||
)
|
||||
} else {
|
||||
@ -24,7 +34,12 @@ export const getDeepKeys = (obj: any): string[] => {
|
||||
}
|
||||
|
||||
const parseKey = (key: string) => {
|
||||
if (key.includes(' ') && !key.includes('.map((item) => item')) {
|
||||
if (
|
||||
key.includes(' ') &&
|
||||
!key.includes('.flatMap(item => item') &&
|
||||
!key.includes("['") &&
|
||||
!key.includes("']")
|
||||
) {
|
||||
return `['${key}']`
|
||||
}
|
||||
return `.${key}`
|
||||
|
Reference in New Issue
Block a user