// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Collections.Generic; using System.IO; using Newtonsoft.Json; using Newtonsoft.Json.Linq; namespace E { public class Names { public string Da { get; set; } public string En { get; set; } } public class Category { public int CatId { get; set; } public Names Names { get; set; } } public class Transaction { public int TxId { get; set; } public List Categories { get; set; } } public class Data { public List Transactions { get; set; } } public class Program { public static void Main(string[] args) { Data data = JsonConvert.DeserializeObject(File.ReadAllText("/work/test.json")); foreach(Transaction tx in data.Transactions) { Console.WriteLine(tx.TxId); foreach(Category cat in tx.Categories) { Console.WriteLine(" " + cat.CatId); Names nam = cat.Names; Console.WriteLine(" " + nam.Da); Console.WriteLine(" " + nam.En); } } } } }