我需要用标记“name”和“text”将文本发布到json列表中
@app.route('/', methods=['POST'])
def create_post():
with open('posts.json') as f:
posts = json.load(f)
data = request.data.decode("UTF-8")
posts.append(data)
with open('posts.json', 'w') as f:
f.write(json.dumps(posts))
return json.dumps(posts)
当我使用它时,我会发布文本,但它看起来像这样
"{\"name\": \"exemple\", \"text\": \"exempel\"}"
但我需要这个
{"name": "exempel", "text": "exempel"}
目前没有回答
相关问题 更多 >
编程相关推荐