Reputation: 149
I need some help passing this json dict to the variable RESPONSE
. But I am unsure how to convert this to powershell from bash.
I tried using piping to | ConvertTo-Json -Compress
but couldn't quite get it right
RESPONSE="$(cat <<EOT
{
"spec": {
"instance": "$NODENAME",
"hostname": true,
"container": [
{
"seccontent": {
"objectA": true
},
"image": "$IMAGENAME",
"command": [ "tester", "--target", "1", "--mount", "--test", "--test", "--net", "--pid", "--", "bash", "-l" ]
}
]
}
}
EOT
)"
Upvotes: 0
Views: 43
Reputation: 14667
Try multiple lines string like this:
> $RESPONSE=@'
{
"spec": {
"instance": "$NODENAME",
"hostname": true,
"container": [
{
"seccontent": {
"objectA": true
},
"image": "$IMAGENAME",
"command": [ "nsenter", "--target", "1", "--mount", "--uts", "--ipc", "--net", "--pid", "--", "bash", "-l" ]
}
]
}
}
'@
And, then convert to JSON:
> $RESPONSE | ConvertTo-Json
Upvotes: 1