4
我想使用jsonPath和pick功能来确定规则是否需要运行或不是基于当前域。我在做什么的简化版本在这里:使用jsonPath寻找一个字符串
global
{
dataset shopscotchMerchants <- "https://s3.amazonaws.com/app-files/dev/merchantJson.json" cachable for 2 seconds
}
rule checkdataset is active
{
select when pageview ".*" setting()
pre
{
merchantData = shopscotchMerchants.pick("$.merchants[?(@.merchant=='Telefora')]");
}
emit
<|
console.log(merchantData);
|>
}
控制台输出我希望是telefora对象,而不是我从JSON文件中的所有三个对象。
如果不是商家=='Telefora'我使用merchantID == 16,那么它的效果很好。我认为jsonPath也可以对字符串进行匹配。虽然上面的例子不是针对json的merchantDomain部分进行搜索,但我遇到了同样的问题。
感谢您解释'eq'和'=='之间的区别。那一个让462名学生(和其他新人)感到困惑。 – 2011-04-06 03:40:59
不错!我感到困惑,因为我正在查看实际的jsonPath文档,看看我是否可以让这些工作。谢谢Alex! – trumans1 2011-04-06 14:42:20
像这样的情况,运营商会怎么看?我无法使正则表达式正常工作。 – trumans1 2011-04-06 15:18:24