Factor out calls to json.dumps and remove unnecessary temporary variables.