def replace_dots_in_field_names(document):
 for (key, value) in list(document.items()):
  if isinstance(value, dict):
   value = replace_dots_in_field_names(value)
  if (isinstance(key, string_types) and (key.find('.') != (-1))):
   del document[key]
   document[key.replace('.', '_')] = value
 return document

def replace_dots_in_field_names ( document ) : for ( key , value ) in list ( document . items ( ) ) : if isinstance ( value , dict ) : value = replace_dots_in_field_names ( value ) if ( isinstance ( key , string_types ) and ( key . find ( '.' ) != ( - 1 ) ) ) : del document [ key ] document [ key . replace ( '.' , '_' ) ] = value return document
this method destructively modifies document by replacing any dots in field names with an underscore .