In JSON format, I have a message that contains various details. My goal is to utilize Javascript search functionality to identify if the EmailAddress matches the specific value I am looking for within hundreds of similar messages:
"Message": {
"Event": {
"Type": "INFO",
"IsSuccessful": true,
"Details": {
"Value": "{\"EmailAddress\":\"<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="bfcbdacccbffcbdacccb91dcd0d2">[email protected]</a>\",\"SystemId\":\"5\"}"
}
This is the code snippet I have been using:
function findItem(items) {
if (!items) return console.log('failed');
for (i=0; i < items.length; i++) {
if (items[i].Event.Details.Value.EmailAddress === "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="0c78697f784c78697f78226f6361">[email protected]</a>\") return console.log('found');
}
return console.log('fail 2');
}
return findItem(Context.Message);
I seem to be encountering an issue as my search function is not triggering the console.log('found')
UPDATE* I would like to mention that this scenario involves the use of Kafka Magic Tool - https://www.kafkamagic.com/usage/development/#:~:text=validating%20a%20producer.-,Use%20JavaScript%20queries%20to%20search%20for%20a%20message,fields%2C%20headers%2C%20and%20metadata.