bag_has_key()

Controlla se un oggetto contenitore di proprietà dinamiche contiene una chiave specificata.

Sintassi

bag_has_key(Borsa,Chiave)

Altre informazioni sulle convenzioni di sintassi.

Parametri

Nome Tipo Obbligatoria Descrizione
bag dynamic ✔️ Contenitore delle proprietà da cercare.
key string ✔️ Chiave da cercare. Cercare una chiave nidificata usando la notazione JSONPath . L'indicizzazione di matrici non è supportata.

Restituisce

True o false a seconda che la chiave esista nel contenitore.

Esempio

datatable(input: dynamic)
[
    dynamic({'key1' : 123, 'key2': 'abc'}),
    dynamic({'key1' : 123, 'key3': 'abc'}),
]
| extend result = bag_has_key(input, 'key2')

Output

input result
{
"key1": 123,
"key2": "abc"
}
true
{
"key1": 123,
"key3": "abc"
}
false

Eseguire ricerche usando una chiave JSONPath

datatable(input: dynamic)
[
    dynamic({'key1': 123, 'key2': {'prop1' : 'abc', 'prop2': 'xyz'}, 'key3': [100, 200]}),
]
| extend result = bag_has_key(input, '$.key2.prop1')

Output

input result
{
"key1": 123,
"key2": {
"prop1": "abc",
"prop2": "xyz"
},
"key3": [
100,
200
]
}
true