Search code examples
powershellazure-cli

How can i format Json data for Powershell?


How can i format the following json body to make a rest request inb powershell az cli ? It has json data in json data , its a bit different than the standard .

 {"Id":"1234","Name":"acme","Model":{"CustId":"789","CustName":"","Roles": 
   ["admin"]},"SubscriptionId":1,"Email":"cust@test.com"}

How do i format this in Powershell ?


Solution

  • Your JSON data is not formatted strange in any way, but you need to handle the expression as a string in PowerShell first...

    '{
      "Id":"1234",
      "Name":"acme",
      "Model":
      {
        "CustId":"789",
        "CustName":"",
        "Roles":["admin"]
      },
      "SubscriptionId":1,
      "Email":"cust@test.com"
    }'