I need to map json having property name with dots to the equivalent nested c# classes.
For e.g. I have JSON string as below:
{
"DateProcessed": "20170215T005736+0530", //e.g.to ProcessedDate in C# class
"WordCount" :346,
"Content.Headline": "This is just the headline",
"Content.Href": "http://www.samplesssss.test",
"Content.Text": "This is the big text represntation here that defines the summary structure.",
"Content.Thumbnail.Href" : "http://imagetest.test.intr",
"Content.Thumbnail.Height" : "245",
"Content.Thumbnail.Width" :"345",
"Content.Thumbnail.UnitType" :"centimeter"
}
I need to map the above JSON string to the C# class mentioned below:
public class Body
{
public Datetime ProcessedDate {get;set;}
public int WordCount {get;set;}
public Format Content {get;set;}
}
public class Content
{
public string Headline {get;set;}
public string Href {get;set;}
public string Text {get;set;}
public ImageHolder Thumbnail {get;set;}
}
public class ImageHolder
{
public string Href {get;set;}
public int Height {get;set;}
public int Width {get;set;}
public string UnitType {get;set;}
}
Really clueless as how to map the above JSON with C# Classes. I tried with traditional approach by splitting string and trying to find equivalent matching property name in C# class but it became so messy I had to stop it and delete everything. Any approach will be really helpful. Hope SO expertise will save my day.