api 调用的 ColdFusion json 结果:如何寻址名称中带有空格的字段?
我执行 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 技术交流群。

对于此类情况,最好的方法是规避 dot.notation 并尝试 bracket["notation"],如下所示:
For situations like these the best way is to circumvent dot.notation and try bracket["notation"] like this: