Search notes:

PowerShell cmdLet ConvertTo-JSON

convertTo-json converts PowerShell objects to JSON documents (a System.String object).
$obj = [psObject] @{
  txt = 'Hello world'
  num =  42
  bla = 'foo', 'bar', 'baz'
}

convertTo-json $obj
#
# {
#   "bla": [
#     "foo",
#     "bar",
#     "baz"
#   ],
#   "txt": "Hello world",
#   "num": 42
# }
Github repository about-PowerShell, path: /cmdlets/json/convertTo/basic.ps1

See also

convertFrom-json parses a string that contains a JSON value to a PowerShell object.
Powershell command noun: json

Index