I have a JavaScript dictionary that I want to pass to a Python app on app engine, put into datastore, retrieve from datastore and finally return as JSON. What's the right way to do it?
Say it looks something like that:
dict = {'box': 'huge',
'crayons': [{ 'color': 'blue', 'l': 12 },
{ 'color': 'red', 'l': 2 },
{ 'color': 'yellow', 'l': 7 }]};
I serialize it using jQuery:
data = $.param(dict);
getting something 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 it using $.ajax to app engine (Python, Flask) and put it into datastore as a serialized string. Later I want to deserialize it to a Python dictionary and translate it to JSON using simplejson.
I have no idea how to deserialize it to a Python dictionary though.
Edit: Or maybe I'm doing it wrong and need to pass the dictionary to app engine differently?