简体   繁体   中英

How to fetch data from nested JSON response and pass to next request in postman?

I have a JSON response as below.

{
    "SearchId": "AD9AD002JKLNLSF7",
    "TanxId": "789456g78udk9",
    "Test": [{
        "Outgoing": [{
            "Identifier": null,
            "AirId": "eff4f689-8b49",
            "Fare": "a0b8ac00-e6ab"
        }]
    }]
}

How can I get value of "AirId" and "Fare" from this response and pass to next request?

I tried below but it's not working.

var FareId = jsonData.Test[0].Outgoing.Fare;
pm.globals.set(“Fareref”, FareId);

Here is an example:

var oJson = JSON.parse('{ "SearchId": "AD9AD002JKLNLSF7", "TanxId": "789456g78udk9", "Test": [{ "Outgoing": [{ "Identifier": null, "AirId": "eff4f689-8b49", "Fare": "a0b8ac00-e6ab" }] }] }');

console.log(oJson.Test[0].Outgoing[0].AirId);
console.log(oJson.Test[0].Outgoing[0].Fare);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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