If the event message is a JSON string, then pretty print the JSON with 2 indents and sort the keys. This makes
        it very easy to visually parse and search JSON data

def format_json(event, colored):
        """
        If the event message is a JSON string, then pretty print the JSON with 2 indents and sort the keys. This makes
        it very easy to visually parse and search JSON data
        """

        try:
            if event.message.startswith("{"):
                msg_dict = json.loads(event.message)
                event.message = json.dumps(msg_dict, indent=2)
        except Exception:
            # Skip if the event message was not JSON
            pass

        return event