I’ve had a quick play with PowerShell, but haven’t spent too much time on this.
Based on the following content file. (testFile.json)
[
{
"id": null,
"geohash": null,
"latitude": 19.26362,
"sequence": 0,
"longitude": 73.07356,
"googleAddress": null
},
{
"id": null,
"geohash": null,
"latitude": 19.26045,
"sequence": 1,
"longitude": 73.06872,
"googleAddress": null
}
]
The following uses the ConvertTo-Json -compress option to minify the JSON and removing any line breaks, etc.
$importFile = Get-Content -Raw testFile.JSON
$json = (ConvertFrom-Json $importFile) | ConvertTo-Json -Compress
$body = @(
@{jsonObject = $json }
)
ConvertTo-Json -InputObject $body
The above is nearly there, but not exactly how I would want it.
It creates the array, with the single object in it.
But the $json object is treated as a string instead of the array.
[
{
"jsonObject": "[{\"id\":null,\"geohash\":null,\"latitude\":19.26362,\"sequence\":0,\"longitude\":73.07356,\"googleAddress\":null},{\"id\":null,\"geohash\":null,\"latitude\":19.26045,\"sequence\":1,\"longitude\":73.06872,\"googleAddress\":null}]"
}
]
For your use case, this might be ok as you can then parse the string in the pre-request script in Postman.
You might want to pose a question on Stack Overflow or on the Microsoft forums as this is more of a PowerShell query at this point in time.