Skip to content

TypeError: the JSON object must be str, not 'bytes' #17

@emtoonst

Description

@emtoonst

After using python3 gcexport3.py and logging in I get the error 'TypeError: the JSON object must be str, not 'bytes''

I have solved this issue by detecting the encoding :
Instead of LIST = json.loads(ACTIVITY_LIST) use:
LIST = json.loads(ACTIVITY_LIST.decode(chardet.detect(ACTIVITY_LIST)["encoding"]))

and instead of #JSON_SUMMARY = json.loads(ACTIVITY_SUMMARY) use:
JSON_SUMMARY = json.loads(ACTIVITY_SUMMARY.decode(chardet.detect(ACTIVITY_SUMMARY)["encoding"]))

you have to install and use the module chardet:
pip3 install chardet
add 'import chardet' to gcexport3.py

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions