【问题标题】:apigee - Json payload extract variablesapigee - Json 有效负载提取变量
【发布时间】:2014-07-14 21:52:41
【问题描述】:

我很困惑为什么我使用的 extractVariables 规则会按原样返回数据。见下文。

要解析的json是:

{
    "callNotificationSubscriptionList": {
        "playAndCollectInteractionSubscription": [],
        "recognitionInteractionSubscription": [],
        "playAndRecordInteractionSubscription": [],
        "callDirectionSubscription": [],
        "callEventSubscription": [
            {
                "clientCorrelator": "112345",
                "resourceURL": "http:someurl",
                "callbackReference": {
                    "notifyURL": "someotherurlt",
                    "notificationFormat": "XML"
                },
                "filter": {
                    "data1": "data abc",
                    "data2": "data def",
                    "data3": "data xyz"
                }
            }
        ]
    }
}

规则:

<JSONPayload>
    <Variable name="callNotSubL">
        <!-- <JSONPath>$.callNotificationSubscriptionList</JSONPath> -->
        <JSONPath>$.*</JSONPath>
    </Variable>
</JSONpayload>

当我使用被注释掉的值时,我没有得到响应变量数据。如果我将“ignoreUnresolvedVariables”参数设置为“false”,我将返回失败,因此它没有数据。因此,我尝试了 "$.*" 有了这个,我被退回了:

[
    {
        "callbackReference": {
            "notifyURL": "someotherurlt",
            "notificationFormat": "XML"
        },
        "filter": {
            "data1": "data abc",
            "data2": "data def",
            "data3": "data xyz"
        }
    }
]

这可能是因为 EntryNames 太长了吗?我承认它们很长,但它们远低于 JSON Threat Potection Policy 中的默认值。

我确实通过基于 Web 的 JSONPayload 解析器和 $.callNotificationSubscriptionList 和 $.callNotificationSubscriptionList.callEventSubscription[0] 工作正常来抽取这个 json,这正是我真正追求的。但是,如果我不能正确获得顶级,我就根本无法获得子级别。

【问题讨论】:

    标签: json variables extract apigee


    【解决方案1】:

    我使用@Santanu的cmets解决了这个问题:

    似乎通过策略解析的 JSON 与您期望的不一样?您能否尝试在 JSON 路径提取策略之前使用 AssignVariable 策略将整个有效负载分配给变量,并在调试视图中检查该变量的值?当您尝试应用 json 路径提取策略时,这将有助于了解实际传递的有效负载值。

    &lt;Source&gt; 标签是“请求”,这是响应摘录。我删除了&lt;Source&gt; 标签,一切都很好

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-05-10
      • 1970-01-01
      • 2022-06-14
      • 1970-01-01
      • 2015-11-02
      • 2021-04-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多