0

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
)"

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

1 Comment

That did it! Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.