internal class Program { static void Main(string[] args) { var txt=File.ReadAllLines(@"3.txt").Where(i=>!i.StartsWith("-")).ToList(); Root root = new Root(); root.date = txt[0].Replace("Date :"," "); root.machineId = txt[1].Split(':')[1]; root.userId= txt[2].Split(':')[1]; root.type= txt[3].Split(':')[1]; root.notes = new List(); root.notes.Add(new Note() { @this= Convert.ToInt32( txt[5].Split(' ')[0]),that = Convert.ToInt32(txt[5].Split(' ')[1]),total = Convert.ToInt32(txt[5].Split(' ')[2]) }); root.notes.Add(new Note() { @this = Convert.ToInt32(txt[6].Split(' ')[0]), that = Convert.ToInt32(txt[5].Split(' ')[1]), total = Convert.ToInt32(txt[6].Split(' ')[2]) }); root.notes.Add(new Note() { @this = Convert.ToInt32(txt[7].Split(' ')[0]), that = Convert.ToInt32(txt[5].Split(' ')[1]), total = Convert.ToInt32(txt[7].Split(' ')[2]) }); root.notes.Add(new Note() { @this = Convert.ToInt32(txt[8].Split(' ')[0]), that = Convert.ToInt32(txt[5].Split(' ')[1]), total = Convert.ToInt32(txt[8].Split(' ')[2]) }); root.notes.Add(new Note() { @this = Convert.ToInt32(txt[9].Split(' ')[0]), that = Convert.ToInt32(txt[5].Split(' ')[1]), total = Convert.ToInt32(txt[9].Split(' ')[2]) }); root.total = Convert.ToInt32(txt[11].Split(' ')[0]); root.totalAmount=Convert.ToInt32(txt[13].Split(' ')[0]); string jsonString =JsonConvert.SerializeObject(root); } } public class Note { public int @this { get; set; } public int that { get; set; } public int total { get; set; } } public class Root { public string date { get; set; } public string machineId { get; set; } public string userId { get; set; } public string type { get; set; } public List notes { get; set; } public int total { get; set; } public int totalAmount { get; set; } }