'Kusto extractjson not working with email address

I am attempting to use the extractjson() method that includes email addresses in the source data (specifically the @ symbol).

let T = datatable(MyString:string)
[
    '{"[email protected]": {"value":10}, "userdomain.com": { "value": 5}}'
];
T
| project extractjson('$.["[email protected]"].value', MyString)

This results in a null being returned, changing the JSONPath to '$.["userdomain.com"].value' does return the correct result.

Results

I know the @ sign is a used as the current node in a filter expression, does this need to be escaped when used with KQL?

Just as a side note, I run the same test using nodes 'jsonpath' package and this worked as expected.

const jp = require('jsonpath');
const data = {"[email protected]": {"value":10}, "name2": { "value": 5}};

console.log(jp.query(data, '$["[email protected]"].score'));


Solution 1:[1]

you can use the parse_json() function instead, and when you don't have to use extract_json():

print MyString = '{"[email protected]": {"value":10}, "userdomain.com": { "value": 5}}'
| project parse_json(MyString)["[email protected]"].value

From the documentation: https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/extractjsonfunction

enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Yoni L.