I'm trying to get this kind of json body to send it to graph API for a patch.
json {
"description": "Something",
"previewType": "noPreview",
"checklist":
{
"18907":
{
"title": "Title 1"
"isChecked": "True"
}
},
{
"35669":
{
"title": "Title 2"
"isChecked": "True"
}
},
{
"41911":
{
"title": "Title 3"
"isChecked": "True"
}
}
}
Here is the code, but I can't get the desired result
$json = @{
description = $sourceTaskDetails.Description;
previewType = $sourceTaskDetails.previewType;
}
$checklist = @()
foreach($object_properties in $details.checklist.PsObject.Properties)
{
$checklist+= @{
$object_properties.Name =
@{
title = $object_properties.Value.title;
isChecked = $object_properties.Value.isChecked;
}
}
}
$taskDetailsPayload.Add("checklist", $checklist)
$jsonTaskDetailsPayload = $taskDetailsPayload | ConvertTo-Json
How do I structure it correctly to get what I shown above, because at this moment instead of title and isChecked I just get the "18907": "System.Collections.Hashtable"
Thanks in advance