using System; using System.IO; using ln.json; using ln.json.mapping; namespace json.test { class MainClass { static string[] sources = { "\"I am a string\"", "{ \"me\" : \"is a string too\"}", "[ \"this\", \"is\", \"an\", \"array\" ]" }; public static void Main(string[] args) { JSONObject json = new JSONObject() .Add("version", new JSONNumber(123.456)) .Add("text", new JSONString("Ich bin ein Text! Lächerlich, oder?")) .Add("Obst",new JSONArray() .Add(new JSONString("Apfel")) .Add(new JSONString("Birne")) .Add(new JSONString("Zwetschge")) .Add(JSONNull.Instance) .Add(JSONTrue.Instance) .Add(JSONFalse.Instance) ) ; Console.WriteLine(json.ToString()); JSONValue json2 = JSONParser.Parse(json.ToString()); Console.WriteLine(json2.ToString()); JSONValue value = JSONParser.Parse(File.ReadAllText("test.json")); Console.WriteLine(""); Console.WriteLine("test.json file:"); Console.WriteLine("PARSED: {0}",value.ToString()); Person person = new Person() { firstname = "Harald", lastname = "Wolff-Thobaben", age = 39 }; JSONValue jsonPerson = JSONMapper.DefaultMapper.ToJson(person); Console.WriteLine(jsonPerson.ToString()); Person p2 = JSONMapper.DefaultMapper.FromJson(jsonPerson); } class Person { public string firstname; public string lastname; public int age; } } }