Dit was een simpel test programma die ik geschreven heb bij Mediaheads.
(Als je dit wilt compilen moet je SimpleJSON.cs toevoegen)
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using SimpleJSON; using System.Net; using System.IO; namespace jsonparsercs { class Program { static void Main(string[] args) { string savelocation = @"c:\Users\Leonie\Desktop\"; Console.BufferHeight = Int16.MaxValue - 1; WebClient webClient = new WebClient(); string str = "{\"json\":\"failed\"}"; try { webClient.DownloadFile("http://www.leonieponsioen.com/downloads/json.json", savelocation + "json.json"); } catch(WebException e) { Console.WriteLine(e.GetBaseException()); } try { str = File.ReadAllText(savelocation + "json.json"); } catch (FileNotFoundException) { Console.WriteLine("FILE NOT FOUND"); } JSONNode json = JSON.Parse(str); JsonConverter jc = new JsonConverter(); jc.getData(json); Console.ReadKey(); } } class JsonConverter { public void getData(JSONNode json, string str="") { int i = 0; while (json[i] != null) { if (json[i].GetType() == typeof(JSONClass)) getData(json[i], str + "_"); else if (json[i].GetType() == typeof(JSONArray)) { Console.WriteLine(str+"["); getData(json[i], str); Console.WriteLine(str+"]"); } else Console.WriteLine(str + json[i]); i++; } } } }