Make JSON More Readable
You can use Pandas to better format and explore your JSON responses, but if you just need to quickly make the JSON message more readable, use the following code instead of
# Format the JSON response and print import json print(json.dumps(response, indent=2))
A full code sample, using the above code snippet and calling the
structure endpoint, looks like this:
# Call the API's structure endpoint from scienceio import ScienceIO scio = ScienceIO() query_text = ("ALS is often called Lou Gehrig's disease, after the baseball player who was diagnosed with it. Doctors usually do not know why ALS occurs.") response = scio.structure(query_text) # Format the JSON response and print import json print(json.dumps(response, indent=2))
print(json.dumps(response, indent=7))), or a 1 to slightly decrease it from 2 (
Was this page helpful?
Great! If you ever have questions or want to provide feedback, send us an email.
Bummer. We hate when we miss the mark. If you have suggestions for improvements or other general comments, send us an email.