简体   繁体   English

带有过滤的JSONPath在WSO2 ESB 5中无法正常工作

[英]JSONPath with filtering is not working properly in WSO2 ESB 5

I have a below mentioned like JSONPayload and I want to select the JSON object having hotelcode "ALE1_LON" from the "content" array. 我有一个像JSONPayload的下面提到的,我想从“内容”数组中选择具有酒店代码"ALE1_LON"的JSON对象。

For this I have used "$.content[?(@.hotelcode='ALE1_LON')]" JSONPath expression as mentioned below in the property mediator. 为此,我使用了"$.content[?(@.hotelcode='ALE1_LON')]" JSONPath表达式,如下面在属性介体中所述。

    <property expression="json-eval($.content[?(@.hotelcode='ALE1_LON')])" name="hotelContet" scope="default" type="STRING"/>
    <payloadFactory media-type="json">
        <format>$1</format>
        <args>
            <arg evaluator="xml" expression="get-property('hotelContet')"/>
        </args>
    </payloadFactory>
    <respond/>

Problem is, this returns an empty array. 问题是,这会返回一个空数组。

But when I try same payload and same JSONPath with an online JSONPath Tester it says my JSONPath is correct (sending below like JSON Object). 但是,当我使用在线JSONPath测试程序尝试相同的有效负载和相同的JSONPath时,它表示我的JSONPath是正确的(在下面发送类似于JSON对象)。

[  
   {  
      "hotelcode":"ALE1_LON",
      "hotelname":"Alexandra"
   }
]
  • Why this is not working in WSO2 ESB Propery Mediator? 为什么这不适用于WSO2 ESB Propery Mediator?
  • Is this because of the JSONPath version? 这是因为JSONPath版本?
  • WSO2 is not supported this way? 这种方式不支持WSO2吗?
  • Do I need to iterate each element and filter? 我是否需要迭代每个元素并过滤?

JSON Payload : JSON有效载荷:

{
    "_id":"INV27_1112",
    "_rev":"5-876038bf65752ce4505e50baea6d5581",
    "content":[
        {
            "hotelcode":"AMB3_LON",
            "hotelname":"Ambassadors Bloomsbury"
        },
        {
            "hotelcode":"ALE1_LON",
            "hotelname":"Alexandra"
        },
        {
            "hotelcode":"ALO_LON",
            "hotelname":"Aloft London Excel"
        }
    ]
}
  • WSO2 ESB version : 5.0.0 WSO2 ESB版本:5.0.0

Note : "json-eval($.content[0])" like exprssions return results correctly 注意: "json-eval($.content[0])" .content "json-eval($.content[0])"就像exprssions正确返回结果一样

References : 参考文献:

Error is with the json-eval expression. 错误与json-eval表达式有关。 == must be used for equality not =. ==必须用于平等而不是=。 eg : json-eval($.content[?(@.hotelcode=='ALE1_LON')]) works fine. 例如: json-eval($.content[?(@.hotelcode=='ALE1_LON')])工作正常。 Thank you for the support. 谢谢你的支持。 Reference : https://odieweblog.wordpress.com/2015/09/20/new-json-path-expression-predicates/ , http://madhukaudantha.blogspot.com/2017/02/wso2-esb-with-javascript-object-notation.html 参考: https//odieweblog.wordpress.com/2015/09/20/new-json-path-expression-predicates/,http : //madhukaudantha.blogspot.com/2017/02/wso2-esb-with-javascript -object-notation.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM