omdbapi / OMDb-API

The Open Movie Database Bug Tracking
418 stars 21 forks source link

JSON Response Formatted Inncorrectly #239

Open meisnate12 opened 3 years ago

meisnate12 commented 3 years ago

I did this search by accident and got a json decode error

http://omdbapi.com/?i=tt011f8539&apikey=APIKEY
SyntaxError: JSON.parse: expected ',' or '}' after property value in object at line 1 column 54 of the JSON data

this was the Raw data returned:

{"Response":"False","Error":"Conversion from string "011f8539" to type 'Double' is not valid."}

im pretty sure the problem stems from have the " inside the error string when it should probably just be '

Fezlight commented 3 years ago

I think your issue is related to a bad imdb id, there is a letter 'f' inside your imdb id wich cause a conversion error. I think an imdb id format can be like this "tt[0-9]*". if you remove the 'f' you will obtain https://omdbapi.com/?i=tt0118539, is this the correct movie ?

meisnate12 commented 3 years ago

The problem isn't that the ID doesn't work, I know it's not a valid IMDb ID. The problem is the JSON that is being returned when the error occurs is not a valid JSON.

the RAW text being returned is

{"Response":"False","Error":"Conversion from string "011f8539" to type 'Double' is not valid."}

but having non escaped " inside off "Conversion from string "011f8539" to type 'Double' is not valid." makes it an invalid JSON

Fezlight commented 3 years ago

okay ;) i'm sorry, i didn't read correctly your message. Indeed there is an escaping error inside json error response.