nodes: 0, module; 1, function_definition; 2, function_name:format_json; 3, parameters; 4, block; 5, identifier:event; 6, identifier:colored; 7, expression_statement; 8, try_statement; 9, return_statement; 10, comment:"""
          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
          """; 11, block; 12, except_clause; 13, identifier:event; 14, if_statement; 15, identifier:Exception; 16, comment:# Skip if the event message was not JSON; 17, block; 18, call; 19, block; 20, pass_statement; 21, attribute; 22, argument_list; 23, expression_statement; 24, expression_statement; 25, attribute; 26, identifier:startswith; 27, string:"{"; 28, assignment; 29, assignment; 30, identifier:event; 31, identifier:message; 32, identifier:msg_dict; 33, call; 34, attribute; 35, call; 36, attribute; 37, argument_list; 38, identifier:event; 39, identifier:message; 40, attribute; 41, argument_list; 42, identifier:json; 43, identifier:loads; 44, attribute; 45, identifier:json; 46, identifier:dumps; 47, identifier:msg_dict; 48, keyword_argument; 49, identifier:event; 50, identifier:message; 51, identifier:indent; 52, integer:2
code: 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