Hi, I have complex raw data in json, I want to using that in body of power shell script
here is my json:
{
“request”: “success”,
“consent”: true,
“source”: [
{
“type”: " ",
“content”: [
{
“type”: " ",
“meta”: {
“sample_type”: " "
},
“deatail”: " "
}
]
}
],
“destination”: [
{
“type”: " “,
“content”: [
{
“type”: “”,
“meta”: {
“sample_type”: “”,
},
“deatils” :” "
}
]
}
]
}
Hi Sonali29526,
Can you please elaborate your query in detailed?
Thank you.
Assume you’re referring to a REST API body…
#Method 1 - HashTables {} and Arrays ()
$json = @{
Property1 = 'Foo';
Property2='Faa'
PropertyArray = @(@{
Item1 = 'Blah'
Item2 = 'BlahBlah'
})
}
$json | ConvertTo-Json
#Method 2 - Here String with Variables
$variable1 = 'Foo'
$variable2 = 'Faa'
$json = @"
{
"Property1": "$($Variable1)",
"Property2": "$($variable2)",
"PropertyArray": [
{
"Item1": "Blah",
"Item2": "BlahBlah"
}
]
}
"@
$json