Write the json string instead of using dump to file directly.