I am trying to deserialize base64 file attachments from JSON file using JSON.NET. I can deserialize the data using the following code but I am not sure how to decode the base64 files. Please let me know.
Sample JSON file
-----------------
PostData: {
"Main":{
"date1": "14-JAN-2016",
"summary": "summary test",
"Details":[{
"first": "test",
"last": "last test",
},
]}
"attachments":[ {
"title": "Report1.pdf",
"file_name": "Report1.pdf",
"file_content_type": "application/pdf",
"file_format": "binary",
"file_data": "JVBERi0xLjQNCjUgMCBvYmoNCjw8DQovVHlwZSAvWE9iamVjdA0KL1N1YnR5cGUg
MSAwIFIvSW5mbyAxMjYgMCBSL0lEWzw0NTQ3QjRFREZBNjk2NDQ4QjhBNUU4MUQw
QkU4MkVDMD48NDU0N0I0RURGQTY5NjQ0OEI4QTVFODFEMEJFODJFQzA+XSAvUHJl
diAxMTI3OTI5L1hSZWZTdG0gMTEyNjMxNj4+DQpzdGFydHhyZWYNCjExNDAyNTEN
CiUlRU9G",
},
{
"title": "src.txt",
"file_name": "src.txt",
"file_content_type": "text/plain",
"file_format": "text",
"file_data": "bm5gLDJ9NC1DNFkpN20y4tLmM0",
},
]}
}
Program.cs
var json = System.IO.File.ReadAllText("postData.json");
var myJsonObject = JsonConvert.DeserializeObject<PostData>(json);
public class PostData
{
public Main main { get; set; }
}
public class Main
{
public string date1 { get; set; }
public string summary { get; set; }
public List<Details> details { get; set; }
}
public class Details
{
public string first { get; set; }
public string last { get; set; }
}