Generalize convert for dict

The convert function's second argument can be any associative type, not just another dict, so it should be written more generally.