I asked a previous question, and received a brilliant response from mklement0, so thank you for that.
The JSON is:-
{
"results": [
{
"id": 1,
"first_name": "Jeanette",
"last_name": "Penddreth",
"email": "jpenddreth0@census.gov",
"gender": "Female",
"ip_address": "26.58.193.2",
"serverlist": [
{
"myval1": "testdata1",
"myval2": "testdata2",
"myval3": "testdata3"
}
],
"aitlist": [
{
"ait1": "aitdata1",
"ait2": "aitdata2"
}
]
},
{
"id": 2,
"first_name": "Giavani",
"last_name": "Frediani",
"email": "gfrediani1@senate.gov",
"gender": "Male",
"ip_address": "229.179.4.212",
"serverlist": [
{
"myval1": "testdata5",
"myval2": "testdata6",
"myval3": "testdata7"
},
{
"myval1": "testdata9",
"myval2": "testdata10",
"myval3": "testdata11"
}
],
"aitlist": [
{
"ait1": "aitdata3",
"ait2": "aitdata4"
}
]
},
{
"id": 3,
"first_name": "Noell",
"last_name": "Bea",
"email": "nbea2@imageshack.us",
"gender": "Female",
"ip_address": "180.66.162.255"
},
{
"id": 4,
"first_name": "Willard",
"last_name": "Valek",
"email": "wvalek3@vk.com",
"gender": "Male",
"ip_address": "67.76.188.26"
}
]
}
The final piece in the jigsw was that I need to output all the items in the square brackets in the JSON file, for each 'record' together, which is exactly like using the following code would output the data:
(Get-Content -Raw C:\Temp\JsonFile.json | ConvertFrom-Json).Results | Out-GridView
The final output would then look like this:
1,"Jeanette","Penddreth","jpenddreth0@census.gov","Female","26.58.193.2","{@{myval1=testdata1; myval2=testdata2; myval3=testdata3}}","{@{ait1=aitdata1; ait2=aitdata2}}"
Which is how the output appears in Out-GridView
.