Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

"Expecting ',' delimiter". Everything I've tried is not working

My Code:

    with open('music_queue.json', 'r') as f:
         data = f.read()

    list_str = data.split('\n')

    print(list_str)

    db = []

    for d in list_str:
        db.append(json.loads(d))

My raw JSON:

{"guild_id" : 00000, "song_list" : []}

I have tried doing:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

data = data.replace('\"', '\\\"')

only for me to have this error:

Expecting property name enclosed in double quotes: line 1 column 2 (char 1)

I’ve been at this for hours. What’s going on?

Also, apologies if this has already been answered. I literally couldn’t find anything here that I haven’t tried already.

>Solution :

Text inside json files must follow JSON standard and 00000 (without quotes to be marked as string) is not a valid value – replace it with 0 or "00000".

When you open a valid json file you can load the contents straight into a dictionary, like this:

with open('music_queue.json', 'r') as f:
    data = json.load(f)

Example of valid json file:

{"guild_id" : 10000, "song_list" : []}

P.S. You have to use double quotes "" inside json files instead of single quotes ''

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading