javascript - jQuery $.param'ed string parsing in Python (app engine) -
i have javascript dictionary want pass python app on app engine, put datastore, retrieve datastore , return json. what's right way it?
say looks that:
dict = {'box': 'huge', 'crayons': [{ 'color': 'blue', 'l': 12 }, { 'color': 'red', 'l': 2 }, { 'color': 'yellow', 'l': 7 }]};
i serialize using jquery:
data = $.param(dict);
getting like:
box=huge&crayons%5b0%5d%5bcolor%5d=blue&crayons%5b0%5d%5bl%5d=12&crayons%5b1%5d%5bcolor%5d=red&crayons%5b1%5d%5bl%5d=2&crayons%5b2%5d%5bcolor%5d=yellow&crayons%5b2%5d%5bl%5d=7
i send using $.ajax app engine (python, flask) , put datastore serialized string. later want deserialize python dictionary , translate json using simplejson.
i have no idea how deserialize python dictionary though.
edit: or maybe i'm doing wrong , need pass dictionary app engine differently?
if use $.param lose type information when parsing data. in example number 12 becomes string '12'. boolean true become string 'true'. lead problems when data server.
if maintaining type information important you, might want json encode object before sending app engine (https://github.com/douglascrockford/json-js). put data straight datastore , return on request.
Comments
Post a Comment