// data = output of jsonDecode() sclass JSONKeyTree { new TreeSet out; new MultiMap examples; new Map listSizes; S render(O data) { process(data); ret lines(out, key -> { var xmpls = examples.get(key); var ls = listSizes.get(key); if (ls != null) if (l(ls) == 0) ret key + " with " + nElements(ls.start); else ret key + " with between " + ls.start + " and " + ls.end + " elements"; else if (nempty(xmpls)) ret key + " = e.g. " + jsonEncode(first(xmpls)); else ret key; }); } Set get(O data) { process(data); ret out; } void process(S prefix default "", O data) { if (data cast L) { S l = prefix + " is a list"; out.add(l); listSizes.put(l, joinIntRanges(listSizes.get(l), emptyIntRange(l(data)))); S s = prefix + "[]"; for (O o : data) process(s, o); } else if (data cast Map) { out.add(prefix + " is a map"); for (O key, O val : castMapToMapO(data)) { S s = addDotIfNempty(prefix) + key; out.add(s); process(s, val); } } else if (data == null) out.add(prefix + " is null"); else { out.add(prefix + " is a " + shortClassName(data)); examples.put(prefix, data); } } }