using Newtonsoft.Json.Linq;
using System.Collections.Generic;
public static void Main()
'stuff': ['omg!', 'what?!']
'arrayofheterogenousjunk': [
'achievement': 'win_match'
JObject data = JObject.Parse(json);
IList<string> nodes = flattenJSON(data);
Console.WriteLine(string.Join(Environment.NewLine, nodes));
private static IList<string> flattenJSON(JToken token)
return _flattenJSON(token, new List<string>());
private static IList<string> _flattenJSON(JToken token, List<string> path)
var output = new List<string>();
if (token.Type == JTokenType.Object)
output.AddRange(token.Children().SelectMany(x => _flattenJSON(x, path)));
else if (token.Type == JTokenType.Array)
foreach (var child in token.Children())
var newPath = new List<string>(path);
newPath[newPath.Count - 1] += "[" + arrayIndex++ + "]";
output.AddRange(_flattenJSON(child, newPath));
else if (token.Type == JTokenType.Property)
var prop = token as JProperty;
output.AddRange(_flattenJSON(prop.Value, new List<string>(path) { prop.Name }));
output.Add(string.Join(".", path) + " = " + token.ToString());