elisemercury / Duplicate-Image-Finder

difPy - Python package for finding duplicate or similar images within folders
https://difpy.readthedocs.io
MIT License
420 stars 65 forks source link

query about json #73

Closed simonmcnair closed 10 months ago

simonmcnair commented 1 year ago

Hi, I'm trying to use the json output from search as a variable and using data = json.loads(str(search.result)) but it's failing error Expecting property name enclosed in double quotes: line 1 column 2 (char 1) . I just wondered if you can only use json with file output, and if so, why ?

Cheers Simon

simonmcnair commented 1 year ago

I tried this too:

for key, value in vars(search).items():
        print(key, ":", value)
        if key == 'result':
             data = json.loads(str(value))

sorry if it's wrong. I'm a newb.

elisemercury commented 10 months ago

Hi @simonmcnair,

The json.loads() method can be used to parse a valid JSON string and convert it into a Python Dictionary. Nonetheless, search.result already comes in a Python dict format, hence this function doesn't work here. See here.

Thanks and best, Elise