Stack Exchange
JSONDecodeError: Expecting value: line 1 column 1 (char 0), its throwing error
Below Python code I am using that throws error, i tried readlines, json.loads as well but that doesnt seem to woork as well
with open('/Users/akshayarora/PythonCodes/Capstone1/Delhi.json') as data_file: 
    provinces_json = json.load(data_file)

var dataset = {
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {
        "City": "Delhi",
        "State": "Delhi"
      },
      "geometry": {
        "type": "Point",
        "coordinates": [
          77.266052,
          28.68161
        ]
      }
           ]
    }
           }



--> 355             raise JSONDecodeError("Expecting value", s, err.value) from None
356         return obj, end
JSONDecodeError: Expecting value: line 1 column 1 (char 0)
I tries json.loads as well as but its also throwing error.

Please provide a sample of what the JSON looks like. It's most likely invalid.

It looks like: var dataset = {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"City": "Delhi",
"State": "Delhi"
},
"geometry": {
"type": "Point",
"coordinates": [
77.266052,
28.68161
]
}
},
{
"type": "Feature",
"properties": {
"City": "Delhi",
"State": "Delhi"
},
"geometry": {
"type": "Point",
"coordinates": [
77.266052,
28.68161
]
}
}

like these i have many values, i have provided sample above

Please edit your question to include the JSON. Format the JSON as code, so that it's easier to read. Also, look for non-printing characters at the start of the file.

Please share the entire error message as well as a [mcve], in your post itself.

Does this answer your question? JSONDecodeError: Expecting value: line 1 column 1 (char 0)

@AMC - i tries all those mentioned in the link above but same error is coming

@Akshay We still don't have the necessary information to reproduce this, so I'm not sure what you expect us to be able to do.

TRY WITH THIS JSON:

var dataset = {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"City": "Delhi",
"State": "Delhi"
},
"geometry": {
"type": "Point",
"coordinates": [
77.266052,
28.68161
]
}
]
}
}

Add that to your post, not as a comment, as others have already mentioned. Also, that looks like JavaScript.

That still isn't an [mcve]. The code is incomplete, the data is both invalid JSON and invalid Python. (it looks like JS)

Thats not JSON... JSON is not javascript, it is a way of serializing javascript (or thats what it was designed for). Your var dataset = { is wrong, JSON is not a programming language its a way of storing data structures
Also your JSON is malformed. Your close bracket is in the wrong place
 {"features": [ ... /* HERE */ } /* NOT HERE (where you currently have it) }

(Note comments are not supported in the JSON standard, this is just for show)

I have provided the sample only, so its missing here. in actual file its present

Are you sure? Your saying when you copied it you missed a bracket within it another bracket?? Have you tried this to see if it works?

@Akshay I have provided the sample only, so its missing here. in actual file its present Then it's not a [mcve], right?

reproducable if your code does not actually show the issue then its pointless. This answer is correct for the code you provided, please try it and/or fix your question

@AMC -I have provided sample json through this i am able to reproduce it

@Akshay As I already wrote in another comment, that isn't valid JSON, nor is it even valid Python. We're still missing the entire error message, and the code looks incomplete.

@Akshay What changed? I can't see any difference.
