Use the json library to handle encoding correctly.