将JSONPath过滤器应用于带有空格的字段 [英] Apply JSONPath filter to field with space
本文介绍了将JSONPath过滤器应用于带有空格的字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用JSONPath( https://github.com/jayway/JsonPath )搜索在字段名称中带有空格的文档:
I'm trying to use JSONPath (https://github.com/jayway/JsonPath) to search a document which has spaces in the field names:
{
"model": {
"Details": {
"Nospace": "New today",
"Random nonsense": "New today"
}
}
}
我正在使用 http://jsonpath.herokuapp.com/
这有效:
$.model.Details[?(@.Nospace== 'New today')]
但这不是:
$.model.Details[?(@.'Random nonsense'== 'New today')]
这可以,但是缺少过滤器表达式:
This does but is missing the filter expression:
$.model.Details['Random nonsense']
所以似乎可以用空格来引用字段,但是我还没有找到如何在过滤器中使用它们的方法.是否有可能?我尝试了许多其他组合但都没有运气,而且似乎也没有在网上找到任何相关信息.
So it seems it's possible to refer to fields with spaces, but I haven't found how to use them in a filter. Is it possible? I have tried many other combinations with no luck, and don't seem to find anything online about it either.
谢谢.
推荐答案
额外的括号.
$.model.Details[?(@['Random nonsense'] == 'New today')]
这篇关于将JSONPath过滤器应用于带有空格的字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文