From f9af2dc8f0b2eed4fa947e2de8f2d5581145f724 Mon Sep 17 00:00:00 2001 From: Phrozyn Date: Wed, 14 Nov 2018 09:57:47 -0600 Subject: [PATCH] Updated code that works on subkeys. --- mq/plugins/lower_keys.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/mq/plugins/lower_keys.py b/mq/plugins/lower_keys.py index ed09f95c..8005dba9 100644 --- a/mq/plugins/lower_keys.py +++ b/mq/plugins/lower_keys.py @@ -16,6 +16,16 @@ class message(object): self.priority = 5 def onMessage(self, message, metadata): - if isinstance(message, dict): - message = dict((k.lower(), v) for k, v in message.items()) - return (message, metadata) + def renameKeysToLower(message): + if isinstance(message, dict): + for key in message.keys(): + message[key.lower()] = message.pop(key) + if isinstance(message[key.lower()], dict) or isinstance(message[key.lower()], list): + message[key.lower()] = renameKeysToLower(message[key.lower()]) + elif isinstance(message, list): + for item in message: + item = renameKeysToLower(item) + return message + + message = renameKeysToLower(message) + return (message, metadata)