• Register
0 votes
395 views

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

Please log in or register to answer this question.

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()

 OR

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 7.1K views
7.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, 2020 alecxe 7.5k points
0 votes
1 answer 62 views
62 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 366 views
366 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, 2020 jwilliam 3.9k points
0 votes
1 answer 12 views
12 views
Problem: OS: Windows 8 64bit with the latest update. Objective: Run Python.exe with Powershell as an administrator. I've changed the path to include the script but when I try to open Python I get an error code. I receive the same error during the installation.
asked Jan 8 Mashhoodch 5.6k points
0 votes
1 answer 142 views
142 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, 2020 Raphael Pacheco 4.9k points
0 votes
1 answer 392 views
392 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
0 votes
1 answer 482 views
482 views
Problem : Currently I am facing some issues. I am trying to use C# with Json.NET. The problem is that I always get following error: {"Unexpected character encountered while parsing value: e. Path '', line 0, position 0."} So the way I amm using Json.NET is ... as follows: {"Unexpected character encountered while parsing value: e. Path '', line 0, position 0."} Does anyone have any solution on it?
asked Dec 9, 2019 alecxe 7.5k points
0 votes
1 answer 1.9K views
1.9K views
Problem : I am new to the Python, I am using Python-2.6 CGI scripts but facing following error in the server log while I was doing json.dumps(), Traceback (most recent call last): File "/etc/mongodb/server/cgi-bin/getstats.py", line 135, in <module> print json.dumps ... = datetime.datetime.strftime(now, '%Y-%m-%dT%H:%M:%S.%fZ') print json.dumps({'current_time': now}) // I guess this is the culprit
asked Nov 24, 2019 alecxe 7.5k points