Hey. There was a problem converting the string to json. There is a servachok that communicates with the browser and back-end data. The request arrives from the browser, it is redirected to the engine. The engine sends the answer. The answer goes to the browser and to the console in the form of a converted json. The question is that the first time I get an answer and everything happens wonderfully. The second time it seems like the problem is that I have 2 dictionaries arriving, i.e. two json in one answer.

@app.route('/search/3', methods=['GET', 'POST']) def GetFromBrowser(): if request.method == 'GET': try: connection = requests.get("http://localhost:8082/search/3", params = request.args) except: print("python: Unexpected connection") return "" strJson = connection.text[22:-2] dataJson = json.loads(strJson) ## Здесь происходит крах data = dataJson['result']['poi'][0]['features'] PlotStat(data) return connection.text else: return "" if __name__ == '__main__': app.run(host = '127.0.0.1', port = '8080') 

The collapse looks like this:

 [2017-01-12 10:11:21,602] ERROR in app: Exception on /search/3 [GET] Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1982, in wsgi_app response = self.full_dispatch_request() File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1614, in full_dispatch_request rv = self.handle_user_exception(e) File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1517, in handle_user_exception reraise(exc_type, exc_value, tb) File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1612, in full_dispatch_request rv = self.dispatch_request() File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1598, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/mapsfullsearch/src/estimation/main.py", line 32, in GetFromBrowser dataJson = json.loads(strJson) File "/usr/lib/python2.7/json/__init__.py", line 339, in loads return _default_decoder.decode(s) File "/usr/lib/python2.7/json/decoder.py", line 367, in decode raise ValueError(errmsg("Extra data", s, end, len(s))) ValueError: Extra data: line 1 column 7 - line 1 column 1185 (char 6 - 1184) 
  • What is the content of strJson ? - faoxis
  • @faoxis, probably there, there really was some JSON. The problem is solved as follows: if (strJson[0] != "{"): strJson = "{" + connection.text[22:-2] + "}" - hedgehogues

0