views:

38

answers:

1

Hi,
I need to get data from JSON, transfered by ajax from client. Basically I used something like this:

@route('/ajax')
def serve_ajax():
    return main.parse_request(json.dumps(dict(request.GET)))

Where main.parse_request is a function, that contains some logics to deal with variables in JSON (it is a main procedure of our game engine).

So the problem is that I can't correctly handle JSON vars, by transforming request.GET in a dict: cause in a way, that I already wrote I can't pass nested objects and arrays, also every value has a string type, while I need to have integer types on integers and string type on rest other.

Or, since I can obtain original query string (by request.query_string), how can I convert query string into original JSON object?

A: 

Try this:

http://www.dotnetspeaks.com/DisplayArticle.aspx?ID=80

Sumit
You mean to use json2.js for converting all necessary JSON-based data in string before sending? I can't say that this is beautiful solution, for sure it will work, cause python can decode any incoming string as JSON, but also I need to wrap any ajax calls in client.I hope that there is also another way to do the same thing, I wonder if there is any 3rd-party library for python to decode query strings as non-standart JSONDecoder
kravitz