Skip to content

Instantly share code, notes, and snippets.

@embarq
Created June 15, 2016 18:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save embarq/a5766704418e420e5e48b82e4007e61b to your computer and use it in GitHub Desktop.
Save embarq/a5766704418e420e5e48b82e4007e61b to your computer and use it in GitHub Desktop.
JSON Import
class Program
{
static void Main(string[] args)
{
string[] files = Directory.GetFiles(@"../../", "*.json");
foreach(string filename in files)
{
Console.WriteLine("File: " + filename);
List<dynamic> data = import(filename);
foreach(dynamic subset in data)
{
foreach (JProperty prop in subset.Properties())
{
Console.WriteLine('\t' + prop.Name + ": " + prop.Value);
}
}
Console.WriteLine("");
}
Console.ReadLine();
}
static List<dynamic> import(string filename)
{
//Dictionary<string, string> data = new Dictionary<string, string>();
List<dynamic> data = new List<dynamic>();
dynamic jsonData = JArray.Parse(File.ReadAllText(filename));
foreach (dynamic item in jsonData)
{
data.Add(new JObject(item));
}
return data;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment