我正在编写一个 Python 脚本来将一些 JSON 文件输出到 Azure 上的 Cosmos DB。我的脚本如下所示:
import logging
import uuid
import json
import azure.functions as func
def main(event: func.EventHubEvent, message: func.Out[func.Document]) -> None:
event_body = event.get_body().decode('utf-8')
logging.info('Python event trigger function processed an event item: %s',event_body)
data = {
"value": event_body,
"insertion_time": event_body
}
message.set(func.Document.from_json(json.dumps(data)))
输出是这样写的:
{
"value": "{\n \"value\": \"66\",\n \"insertion_time\": \"2020-06-02T05:50:00+00:00\"\n}",
"insertion_time": "{\n \"value\": \"66\",\n \"insertion_time\": \"2020-06-02T05:50:00+00:00\"\n}"
}
但是,我希望它是这样的:
{
"value": "66",
"insertion_time": "2020-06-02T05:50:00+00:00"
}
我该如何纠正这个问题?
海绵宝宝撒
相关分类