If you want to stick with this inefficient approach, you'll need the JSON property names to be prefixed with the "@" character:
public class SyncActivity
{
[JsonProperty("@MemberId")]
public string MemberId { get; set; }
[JsonProperty("@UserId")]
public string UserId { get; set; }
[JsonProperty("@CreatedBy")]
public int CreatedBy { get; set; }
[JsonProperty("@UpdatedBy")]
public int UpdatedBy { get; set; }
[JsonProperty("@UpdatedDate")]
public DateTime UpdatedDate { get; set; }
}
Converting between JSON and XML[
^]
But converting your object to JSON just to convert it back to XML is horribly inefficient. It would be much simpler to convert the object directly to XML:
XDocument document = new XDocument(
new XElement("root",
Activities.General.Select(a => new XElement("General",
new XAttribute("MemberId", a.MemberId),
new XAttribute("UserId", a.UserId),
new XAttribute("CreatedBy", a.CreatedBy),
new XAttribute("UpdatedBy", a.UpdatedBy),
new XAttribute("UpdatedDate", a.UpdatedDate)
)),
Activities.RA.Select(a => new XElement("RA",
new XAttribute("MemberId", a.MemberId),
new XAttribute("UserId", a.UserId),
new XAttribute("CreatedBy", a.CreatedBy),
new XAttribute("UpdatedBy", a.UpdatedBy),
new XAttribute("UpdatedDate", a.UpdatedDate)
)),
Activities.WA.Select(a => new XElement("WA",
new XAttribute("MemberId", a.MemberId),
new XAttribute("UserId", a.UserId),
new XAttribute("CreatedBy", a.CreatedBy),
new XAttribute("UpdatedBy", a.UpdatedBy),
new XAttribute("UpdatedDate", a.UpdatedDate)
))
)
);
This will also give you complete control over the format of the generated XML document.