LoadRunner中的Json响应

问题描述

我有这个Json回复

{
    "data": {
            "key": "7316970d1ed2ac72f17cdf481866ec812ae3f9387620bd1cece82567d222786566ebb8b485caf97c","card": {
                    "display_number": "54****5166","url_image": "75210502455|FIESTA REWARDS CLASICA"
                },"card_current_balance": {
                    "currency_code": "MXN","amount": 21100
                },"statements": [
                    {
                        "key": 18,"description": "Corte actual","transactions": []
                    },{
                        "key": 17,"description": "Del 8 de septiembre al 8 de octubre",{
                        "key": 16,"description": "Del 9 de agosto al 8 de septiembre","transactions": [
                                {
                                    "key": 14,"posted_date": "10/08/2020 12:00:01 a. m.","description": "CIA DE GAS DE MORELOS","amount": {
                                            "currency_code": "MXN","amount": 900
                                        }
                                },{
                                    "key": 4,"posted_date": "07/08/2020 12:00:01 a. m.","description": "Todo Para SUS PIES","amount": 323
                                        }
                                }
                            ]
                    },{
                        "key": 15,"description": "Del 8 de julio al 7 de agosto","transactions": []
                    }
                ]
        },"notifications": []
}

我需要提取以下数据:

$.data.statements[*].key
$.data.statements[*].transactions[*].key

但是,正如您在Json中看到的一些“交易” 是空的,如何使LR脚本丢弃空的并且仅提取具有两个值的第一条记录? 我希望我很清楚,并感谢您的帮助。

解决方法

您是否尝试过像lr_json_find这样的LR JSON API?

here说明了JSON查询语法。