Using a more robust implementation of json that cleans up the code.