Tau*_*ain 0 python json bottle
我试图用Bottle返回一个Json数组.代码是:
@app.get('/getmyname')
def getmyname():
ret = """{
"chart": {
"type": "column",
}}"""
return json.dumps(ret)
Run Code Online (Sandbox Code Playgroud)
但是我在结果中得到了一些不需要的字符,如下所示:
"{\n\t\t\t\t\"chart\": {\n\t\t\t\t\t\"type\": \"column\",\n\t\t\t\t}}"
Run Code Online (Sandbox Code Playgroud)
我怎么能解决这个问题?
ret是已经 JSON字符串.没有必要打电话json.dumps.
要么ret直接返回,要么将其创建为Python dict,然后将其转储到JSON:
ret = {
"chart": {
"type": "column",
}
}
return json.dumps(ret)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
562 次 |
| 最近记录: |