Why doesn't bottle return lists? [duplicate]
Bottle's JSON plugin can only return objects of dict
type - not list
. There are vulnerabilities related to returning JSON arrays - see this post about JSON hijacking.
As a workaround you may wrap the list
object under dict
with some key say, data as:
def ret_list(): my_data = [ {"name": "John"} ] return {'data': my_data}
Also read Vinay's answer to "How do I return a JSON array with Bottle?".