whenever I create an endpoint to return a list, it returns a number-keyed dictionary instead.
from flask import Flask
app = Flask(__name__)
@app.route('/somelist')
def somelist():
return ['a', 'b', 'c']
When I go to view the endpoint, I get a dictionary like this:
What's going on here? I just want a list!
CodePudding user response:
It is not a dictionary. The 0:
, for example is not part of the response that you've returned.
The browser JSON extension you are using is showing the list along with its indicies.
Instead, use curl or Postman and inspect the raw response without browser response parsing. Or click on the Raw Data
tab...