recursive function to fix json keys mongo doesnt support