I am working on the part of the project where people can click on a book from the search results page, which will then take them to the specific book's page.
I am getting this error:
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Traceback looks like:
obj, end = self.scan_once(s, idx)
During handling of the above exception, another exception occurred:
return self.wsgi_app(environ, start_response)
response = self.handle_exception(e)
reraise(exc_type, exc_value, tb)
raise value
response = self.full_dispatch_request()
rv = self.handle_user_exception(e)
reraise(exc_type, exc_value, tb)
raise value
rv = self.dispatch_request()
return self.view_functions[rule.endpoint](**req.view_args)
return f(*args, **kwargs)
output = json.loads(binary) # This is the only section of code I had a hand in writing
return _default_decoder.decode(s)
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
raise JSONDecodeError("Expecting value", s, err.value) from None
Some iterations of the code I have tried include:
response = requests.get("https://www.goodreads.com/book/review_counts.json", params={"key": key, "isbns": isbn})
source = response.read()
data = json.loads(source)
reviews_count = jsonResponse["books"][0]["reviews_count"]
average_rating = jsonResponse["books"][0]["average_rating"]
response = requests.get("https://www.goodreads.com/book/review_counts.json", params={"key": key, "isbns": isbn})
binary = response.content
output = json.loads(binary)
reviews_count = output["books"][0]["reviews_count"]
average_rating = output["books"][0]["average_rating"]
as well as trying the books.reviews_count
format. I (think) I tried to convert the json object to a python object, but that didn't seem to work either.
I'm looking to get the reviews_count
and average_rating
so I can show it on the book info page (ex: "this book has 4.32 stars based on 356,900 reviews").
I am thinking I am unable to select the part of the json object I want, and I simply don't know the proper formatting. Does that sound right, or have I made a mistake somewhere else?