As suspected, my workaround was to URL encode the "offending" fields at the client end. simpleton.loads() then parsed the json happily. The field could then be "unencoded".
My system has plenty of json passing between clients and the Web2py service. I can't work out why I've tripped over here. On Saturday, 3 November 2018 19:04:20 UTC, Carl Hunter Roach wrote: > > I've had a stable web2py-based service for some years now. > But it broke today with a small change in a data value - that's my working > hypothesis. > > The output of the print statement (see code below): > > <Storage > {'{"sort":"relevancy","longitude":-0.1228710438544765,"keywords":"parrot","latitude":51.51158325978085,"page_cursor":"A2ebAAFVVvv0OW53MHyzU0VWVVBxb0tiUW9oWkd0UHMzU09aUjIwYUFBPT0jMTA': > > '"}'}> > > > The value of "page_cursor" sent by the caller is "page_cursor" : > "A2ebAAFVVvv0OW53MHyzU0VWVVBxb0tiUW9oWkd0UHMzU09aUjIwYUFBPT0jMTA=' i.e. > there is an "=" suffix. But by the time my controller receives the > json structure the "=" has been mangled. This obviously defeats the > simplejson loads function as the data is no longer valid json. Previous to > today page_cursor values have been more straightforward and not included a > "=" character and the code has executed fine. > > Any suggestions? A fix or a different approach to parsing request.post_vars > > The call is to: https://…/api/v1/article_search > > The code excerpts: > > app/controller.py > > @articles_service.json > def get_article(): > from applications.app.modules.article import get_articles > print(request.post_vars) > return get_articles(request.post_vars) > > app/modules/article.py > > def get_articles(json_fields): > ''' > get with a JSON interface > ''' > from gluon.contrib.simplejson import loads > fields = {} > for i in json_fields.keys(): > fields = loads(i) # crashes here. > return … > > routes.py > > routes_in = ( ('/api/v1/$anything', > '/app/controller/call/json/$anything') ) > routes_out = [(x, y) for (y, x) in routes_in] > > > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.