0

假设我有一些 JSON,例如:

{
  "normal": 1,
  "has some spaces": 2,
  "@": 3
}

normal我可以通过简单的查询获得该字段的值:

normal

但是我无法获得其他两个字段。我努力了:

[has some spaces]
'has some spaces'
['has some spaces']
"has some spaces"
["has some spaces"]
{has some spaces}
{'has some spaces'}
{"has some spaces"}

但它们都不起作用

4

1 回答 1

2

维护者在我提出的一个github 问题上为我解决了这个问题:

导航 JSON 对象部分下,列出了以下内容:

包含空格或保留标记的字段引用可以用反引号括起来

...

`has some spaces`然后JSONata 表达式`@`将分别匹配 2 和 3。

但不是在我通过反复试验发现两种替代方案之前:

$."has some spaces"

$.'has some spaces'
于 2020-08-07T12:44:30.523 回答