gpt4 book ai didi

node.js - 从 Azure 表存储中读取奇怪的 JSON 结构

转载 作者:搜寻专家 更新时间:2023-11-01 00:20:48 24 4
gpt4 key购买 nike

我正在使用 Azure 函数内的 azure-storage 模块从我的 Azure 存储表中读取数据。

像这样获取行

var tableSvc = azure.createTableService();
var query = new azure.TableQuery().top(1000);
tableSvc.queryEntities('tablename', query, null, function(error, result, response) {
// work with result.entries
}

生成的对象看起来很奇怪,因为每个列值都使用“_”键放入它自己的对象中,因此 JSON 看起来像这样:

{
"PartitionKey": {
"$": "Edm.String",
"_": "Keyname"
},
"RowKey": {
"$": "Edm.String",
"_": "Keyname"
},
"Title": {
"_": "The Item Title"
}
}

而不是我所期望的:

{
"PartitionKey": "Keyname",
"RowKey": "Keyname",
"Title": "The Item Title"
}

该表在 Azure 存储资源管理器中看起来很正常。这是正常的吗?或者我能以某种方式影响查询的输出吗?

最佳答案

您可以将负载格式指定为 application/json;odata=nometadata,然后通过 response.body.value 获取结果对象。

var options = { payloadFormat: "application/json;odata=nometadata" };
tableSvc.queryEntities('tablename', query, null, options, function(error, result, response) {
if(!error) {
console.log(response.body.value);
}
}

关于node.js - 从 Azure 表存储中读取奇怪的 JSON 结构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47438161/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com