I already have a Json value got from calling an API, I want to add a new Json List to the exiting Property, So
#calling some API in a loop Start
$apijson = Invoke-WebRequest -Uri $api -ErrorAction SilentlyContinue | ConvertFrom-Json
$response = $apijson| ConvertTo-Json
$null = $data.Add($response);
#calling some API in a loop End
My apiJson will look like the below
{
"host": "tet",
"port": 443,
"protocol": "http",
"isPublic": false,
"status": "READY",
"startTime": 1585220081665,
"testTime": 1585220127003,
"engineVersion": "2.1.0",
"criteriaVersion": "2009q",
"endpoints": [
{
"delegation": 1
}
]
}
Now I have a custom new JsonArray
[
{
"name": "TLE",
"Strength": 128
},
{
"name": "TLS",
"trength": 415
}
]
I want to add the above JsonArray to my original Json Property which makes a full Json like below
{
"host": "tet",
"port": 443,
"protocol": "http",
"isPublic": false,
"status": "READY",
"startTime": 1585220081665,
"testTime": 1585220127003,
"engineVersion": "2.1.0",
"criteriaVersion": "2009q",
"endpoints": [
{
"delegation": 1
}
]
},
"Strength": [
{
"name": "TLE",
"Strength": 128
},
{
"name": "TLS",
"trength": 415
}
]
I tried with Addmember, Concatination nothing working unfortunately.
$api = Invoke-WebRequest -Uri $api -ErrorAction SilentlyContinue | ConvertFrom-Json; $Strength = $JsonArray | ConvertFrom-Json; $api, $Strength | ConvertTo-Json -Depth 5ConvertFrom-JsonJson (like$apijson) as it no longer Json but an general object. I suspect that you also confusing yourself in this matter...