api 调用的 ColdFusion json 结果:如何寻址名称中带有空格的字段?

发布于 01-11 21:38 字数 677 浏览 3 评论 0原文

我执行 Airtable api 调用以在 Airtable 订单表中创建一条记录。用于创建订单的 Airtable api 结果如下所示:

{
    "id":"recj9wqdjnNzN3aiu",
    "fields": {
        "Branch":["rec5S0H7R87QtZ7qJ"],
        "Order no.":129,
        "Order line items":["recePdIxYgfYlKbaR"],
        "Name":"Order #129",
        "OrderPrice (excl VAT)":204.07,
        "RID":"recj9wqdjnNzN3aiu",
        "Product":["rec4j9TqDy8yJXFYg"]
    },
    "createdTime":"2022-03-03T13:20:22.000Z"
}

从该结果中我需要订单号。 要获得名称,我可以做:

<cfset filecontent = deserializeJSON(resultUpdAir.filecontent)>
<cfset orderid = filecontent.records[1].fields.name>

但是我如何获得订单号?字段中是否有空格?

I do an Airtable api call to create a record in our Airtable order table. The Airtable api result for creating the order looks like this :

{
    "id":"recj9wqdjnNzN3aiu",
    "fields": {
        "Branch":["rec5S0H7R87QtZ7qJ"],
        "Order no.":129,
        "Order line items":["recePdIxYgfYlKbaR"],
        "Name":"Order #129",
        "OrderPrice (excl VAT)":204.07,
        "RID":"recj9wqdjnNzN3aiu",
        "Product":["rec4j9TqDy8yJXFYg"]
    },
    "createdTime":"2022-03-03T13:20:22.000Z"
}

From this result I need the Order no.
To get the Name I can do :

<cfset filecontent = deserializeJSON(resultUpdAir.filecontent)>
<cfset orderid = filecontent.records[1].fields.name>

But how would I get the Order no. field since there is a space in it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暖伴2025-01-18 21:38:40

对于此类情况,最好的方法是规避 dot.notation 并尝试 bracket["notation"],如下所示:

<cfset orderid = filecontent.records[1]["fields"]["order no."]>

For situations like these the best way is to circumvent dot.notation and try bracket["notation"] like this:

<cfset orderid = filecontent.records[1]["fields"]["order no."]>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文