How to fix a JSONDecodeError?

I am using Python to write CRUD operations (specifically create and read). I am writing a test script to create and read a dictionary to be later used in the mongoDB shell and have run into a JSONDecodeError.

I am new to python and JSON and have never run into this error before. How can I fix this error? Also, is there any way I can improve the code I am working on?

Thank you!

Here is my test script:

from pymongo import MongoClient
from bson.objectid import ObjectId
import CRUD
from CRUD import AnimalShelter
import random
import string
import json

shelter = AnimalShelter()

animal_id = 'A'.join(random.choices(string.ascii_uppercase + string.digits, k=6))

print('animal_id %s being created' % animal_id)

outcome = json.loads(
    '{"": 78258, "age_upon_outcome": "1.6 years", "animal_id": "" + animal_id + "", "animal_type": "Dog", "breed": "Wolf Sheperd Mix", "color": "Grey", "date_of_birth": "2013-02-09", "datetime": "2014-04-11 13:26:00", "month_year": "2014-04-11T13:26:00", "name": "*JakeMo", "outcome_subtype": "Partner", "outcome_type": "Transfer", "sex_upon_outcome": "Intact Male", "Location_lat": "30.707721081886, "location:long": "-97.2735696278757", "age_upon_outcome_in_weeks": 110.0799603174603}')


if shelter.create(outcome):
  print("animal added")

animal ={"animal_id":animal_id})

And here is the error I get: enter image description here

enter image description here

Read more here:

Content Attribution

This content was originally published by Zane Brown at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: