How to deal with input JSON with varying array lengths when reading from external file

I have a situation where I’m sending JSON input payloads to my API that have arrays whose lengths can vary. I am wondering how to best deal with this when using an external file to populating my request body.

I put a couple snippets of example request bodies - but basically, the “components” , “faultCodes” , “sensors” , “measurements” arrays can all be of varying length (all of which are valid inputs).

So if I want to pull these request bodies in from an external file and have postman iterate through them, how do I need to structure the request body in postman to accept the varying JSON coming from the external file?

For example:
Request body 1:
{
“TestId”: “00”,
“comp”: [
{
“comptName”: “5.01”,
“fault”: [
{
“faultKey”: “1X”,
“faultValue”: 1
},
{
“faultKey”: “2X”,
“faultValue”: 2
},
],
“sensors”: [
{
“SerialNumber”: “600607”,
“measurements”: {
“LFrequency”: {
“x”: {
“unit”: “G”
},
“y”: {
“unit”: “G”
},
“z”: {
“unit”: “G”
},
},
}
}
]
}
],
}

Request body 2:
{
“TestId”: “00”,
“comp”: [
{
“compName”: “5.01”,
“fault”: [
{
“faultKey”: “1X”,
“faultValue”: 1
},
{
“faultKey”: “2X”,
“faultValue”: 2
},
{
“faultKey”: “3X”,
“faultValue”: 3
},
],
“sensors”: [
{
“SerialNumber”: “607”,
“measurements”: {
“LowFrequency”: {
“x”: {
“unit”: “G”
},
“y”: {
“unit”: “G”
},
“z”: {
“unit”: “G”
},
},
}
}
{
“SerialNumber”: “600608”,
“measurements”: {
“LowFrequency”: {
“x”: {
“unit”: “G”
},
“y”: {
“unit”: “G”
},
“z”: {
“unit”: “G”
},
},
}
}
]
}
{
“compName”: “5.02”,
“fault”: [
{
“faultKey”: “1X”,
“faultValue”: 1
},
{
“faultKey”: “2X”,
“faultValue”: 2
},
],
“sensors”: [
{
“SerialNumber”: “600609”,
“measurements”: {
“LowFrequency”: {
“x”: {
“unit”: “G”
},
“y”: {
“unit”: “G”
},
“z”: {
“unit”: “G”
},
},
}
}
]
}
],
}

I realize now that I should simplify this question:

Can nested JSON objects be passed in from an external file at all?

I figured out the answer to this question: Its the same answer I posted in the following link: Comparing API response to JSON in an external file

You can pass the entire JSON in, assign it to an environmental variable in the pre-req using pm.iterationData.get , and then call that environmental variable in the body