如何在jsonpath中转义@符号? [英] How do you escape the @ symbol in jsonpath?

查看:828
本文介绍了如何在jsonpath中转义@符号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给出这样的json列表:

Given a json list like this:

    {    
 "listRel:customFieldList": {
            "platformCore:customField": [
              {
                "@internalId": "801",
                "scriptId": "custentity_admin_contact_cweb",
                "@xsi:type": "platformCore:BooleanCustomFieldRef",
                "platformCore:value": "false"
              },
              {
                "@internalId": "712",
                "@scriptId": "custentity_bar_number",
                "@xsi:type": "platformCore:StringCustomFieldRef",
                "platformCore:value": "166493"
              },
              {
                "@internalId": "798",
                "@scriptId": "custentity_contact_type",
                "@xsi:type": "platformCore:SelectCustomFieldRef",
                "platformCore:value": {
                  "@internalId": "1",
                  "@typeId": "148",
                  "platformCore:name": "Attorney"
                }
              }
              ]
 }
}

如何在"custentity_bar_number"中选择值? 166493?

How can I select the value in "custentity_bar_number"? 166493?

这将带您到达那里,但前提是您删除JSON中@scriptId前面的@符号.

This will get you there, but only if you delete the @ symbol in front of @scriptId in the JSON.

$..['platformCore:customField'][?(@['scriptId'] == 'custentity_bar_number')]

所以我需要的是一种在json中转义@符号并进行类似工作的方法:

So what I need is a way to escape the @ symbol in the json, and make something like this work:

$..['platformCore:customField'][?(@['@scriptId'] == 'custentity_bar_number')]

我正在使用 http://jsonpath.com/尝试使此工作正常.

I am using http://jsonpath.com/ to try and make this work.

推荐答案

您显然需要使用十六进制代码(我认为这与解析表达式的方式有关)

You apparently need to use the hex code (I think it has something to do with the way the expression is being parsed)

$..['platformCore:customField'][?(@['\x40scriptId'] == 'custentity_bar_number')]

这篇关于如何在jsonpath中转义@符号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆