0

I am trying to create JSON object from power shell

$var6 = '{
    "key5":  "value5",
    "key4":  [
                "$Version"
             ],
    "key1":  "value1",
    "key3":  "value3"
    "key6":  {
                "$Version2"
             },
    "key2":  "value2"
}'

I am unable to include these two strings in the JSON

Version: "value1","value2","value3"
Version2: "value3","key1":  "value1", "key2":  "value2"

how to format by using string itself for the required JSON object

  • Really not clear from what you posted what you are trying to do. BTW, you may want to look into ConvertTo-Json and ConvertFrom-Json. – Zoredache Apr 13 '20 at 17:25
  • 1
    @Zoredache is correct; you should look at ConvertTo-Json. Also, string creation using multiple lines will only work with the here-string technique, as described at https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_quoting_rules?view=powershell-7#here-strings. – SamErde Apr 13 '20 at 18:21

0 Answers0