I have a task to fetch the list of all missing updates using a C# .NET Framwork 4.7.2
windows Service which runs at specific intervals.
I have gotten this far to Fetch the Missing updates following this Answer.
Now I need to Put all the Fetched data in a JSON file using the following Format:
{
"hostName": "LRD-SomeHost",
"ip" : "192.168.13.12",
"mac" : "MAC:23:23:123:AS"
"timeStamp" : "CURRENT_TIME_STAMP",
"updates" : [
{
"updateID": "b32e464f-2e4a-4109-9018-33583a079a8a",
"updateDetails": [
{
"patchDescription" : "Some Long Description",
"patchCategory" : "28bc880e-0592-4cbf-8f95-c79b17911d5f"
"patchType" : "UpdateClassification"
"patchName" : "Update Rollups"
},
{
"patchDescription" : "Windows 10"
"patchCategory" : "a3c2375d-0c8a-42f9-bce0-28333e198407"
"patchType" : "Product"
"patchName" : "Windows 10"
},
{
"patchDescription" : "Windows 10 LTSB"
"patchCategory" : "d2085b71-5f1f-43a9-880d-ed159016d5c6"
"patchType" : "Product"
"patchName" : "Windows 10 LTSB"
}
]
}
]
}
Following is my C# Model:
namespace UpdateCollector
{
public class Host
{
public string hostname { get; set; }
public string ip { get; set; }
public string mac { get; set; }
public DateTime? timeStamp { get; set; }
public List<Updates> updates { get; set; }
}
public class Updates
{
public string updateID { get; set; }
public List<UpdateDetails> updateDetails { get; set; }
}
public class UpdateDetails
{
public string patchDescription { get; set; }
public string patchCategory { get; set; }
public string patchType { get; set; }
public string patchName { get; set; }
}
}
My Question is How to put my C# Data in this Format?
Thanks