• Register
0 votes

Problem :

I am facing error “Expecting value: line 1 column 1 (char 0)” when trying to decode the JSON.The URL I use for a API call works fine in a browser, but gives above error when done through the curl request. The error happens at the return simplejson.loads(response_json)

7 5 2
3,870 points

1 Answer

0 votes

Solution :

 The solution is as below:

· There is no need to use a simplejson library, a same library is included with Python as a json module.

· There is no need to decode the response from a UTF8 to unicode, a simplejson / json .loads() method can handle UTF8 encoded data natively.

· pycurl has the very archaic API. Unless you have the specific requirement for using it, there are many other choices.

requests offers a most friendly API, including a JSON support. If you can, replace a call with:

import requests
return requests.get(url).json()


Check a response data-body, whether actual data is present and the data-dump appears to be a well-formatted.

In most cases a json.loads- JSONDecodeError: Expecting value: line 1 column 1 (char 0) error is due to below factors:

· A non-JSON conforming quoting

· XML/HTML output (that is, the string starting with <), or

· A incompatible character encoding

Ultimately an error tells you that at a very first position the string already doesn't conform to the JSON.

9 7 4
38,600 points

Related questions

0 votes
2 answers 5.1K views
Problem : I am trying to figure out the good way to load the JSON objects in the Python. I send below json data: {'http://example.org/about': {'http://purl.org/dc/terms/title': [{'type': 'literal', 'value': "Anna's Homepage"}]}} To my backend where it ... 1 column 2 (char 1)&rdquo; I did lot of research on it but nothing seems to work for me. Any suggestions on my issue will be much appreciated.
asked Jan 7 alecxe 7.5k points
0 votes
1 answer 49 views
Problem : According to the following documents: https://developer.twitter.com/en/docs/tweets/timelines/api-reference/get-statuses-user_timeline.html I have the oauth user token and the user token secret, plus I have my app credentials... The docs state that the ... is supported by Twitter, but how should I include it in the get requests for screen names those are not publicly accessible?
asked Nov 25, 2019 alecxe 7.5k points
0 votes
1 answer 221 views
Problem : Currently I am trying to display a JSON content using a API key. But I am unable to get a authentication. I am facing below error in my JsonObject: &ldquo;Org.json.JSONException: Value Authorization of type java.lang.String cannot be converted to JSONObject&rdquo; In my ... to pass a API key and URL id to get my JSON response in a URL. I display a JSON content using a JSON array.
asked Feb 2 jwilliam 3.9k points
0 votes
1 answer 53 views
Problem: I have fundamental knowledge on java , json and gson. I have below method: public static Object parseStringToObject(String json) {     String Object = json;     Gson gson = new Gson();     Object objects = gson.fromJson(object, Object. ... strange error message: "com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1"
asked Aug 4 Raphael Pacheco 4.9k points
0 votes
1 answer 269 views
Problem : I have spent over the 10 hours in finding the exception or the special character to find in the code but I am unable to find it. I have already checked every similar messages in here. I am facing below error: Syntaxerror: json.parse: unexpected character at line 1 ... my form after that I am sending all the inputs to the main.js to validate it. So, I am just looking for the third-eye.
asked Dec 23, 2019 alecxe 7.5k points