Skip to content
Advertisement

How to fix the Python and JSON Delimiter Expected Error?

I’m entering the following code and receiving the delimiter expected error. From what I can gather JSON Decoder wants a ‘,’ automatically inserted between each record I pull from the For Loop. I can’t seem to find any solution. It pulls one record from the URL, then stops.
Line 1, Column 54 (char 53) does not appear to exist. There are 9 columns on line 1.

JavaScript

Error Message Missing Delimiter

Advertisement

Answer

Yeah, JSON format delimit each element with an , so if your file is not properly formated, the json package will not works.

This does not works so it will raise an error:

JavaScript

But this works fine (because it is properly formatted):

JavaScript

So, you just should gather the data from the file, store it in a variable, update the variable with the new data (it’s what your doing).

But then, don’t append the content to the file, re-write it with the new value (on line 19, use "w" instead of "a":

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement