Given a standard json string value:
$jsonString = \'{ \"baz\": \"quuz\", \"cow\": [ \"moo\", \"cud\" ], \"foo\": \"bar\" }\'
How can I get
I think what you are looking for is this:
$jsonString = @{
'baz' = 'quuz'
'cow'= "moo, cud"
'foo'= "bar"
}
$jsonString|ConvertTo-Json
it produces this output
{
"baz": "quuz",
"cow": "moo, cud",
"foo": "bar"
}
Added note You could also array your cow values to "prettify" it a bit more:
$jsonString = @{
'baz' = 'quuz'
'cow'= @("moo"; "cud")
'foo'= "bar"
}
output:
{
"baz": "quuz",
"cow": [
"moo",
"cud"
],
"foo": "bar"
}