Skip to content

Instantly share code, notes, and snippets.

@samkeen
Created November 14, 2017 16:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samkeen/acfbeff32a7568e41cd4cde9a0b9a7c4 to your computer and use it in GitHub Desktop.
Save samkeen/acfbeff32a7568e41cd4cde9a0b9a7c4 to your computer and use it in GitHub Desktop.
# replace json_api value with parsed value
for key in json_encoded_key_names:
if key in pdp_output.get('product-attributes') and pdp_output['product-attributes'][key] is not None:
try:
pdp_output['product-attributes'][key] = json.loads(pdp_output['product-attributes'][key])
except json.decoder.JSONDecodeError as e:
record_fault('call-resp-processing.atg.missing-required-data',
f"""Invalid JSON: {key} in pdp_output['product-attributes'] Reason:
{e.msg} Data: {pdp_output['product-attributes'][key]}""")
else:
record_fault('call-resp-processing.atg.missing-required-data',
f"Missing required data: {key} in pdp_output['product-attributes'] ")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment