Make JSON More Readable

Two lines of code will make the JSON response easier to read.

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 print(response):

# 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))