using System.Collections.Generic;
public static void Main()
var strings = new List<string>{
"example.anotherstring.1",
"example.anotherstring.2",
var result = strings.Aggregate(new Dictionary<string, Object>(), (acc, s) =>
Dictionary<string, Object> previousLevel = null;
Dictionary<string, Object> nextLevel = acc;
string previousSegment = null;
foreach (string nextSegment in s.Split('.'))
if (Int16.TryParse(nextSegment, out temp))
if (previousLevel[previousSegment] is Dictionary<string, Object>)
previousLevel[previousSegment] = new List<string>();
var list = previousLevel[previousSegment] as List<string>;
if (!nextLevel.ContainsKey(nextSegment))
var child = new Dictionary<string, Object>();
nextLevel.Add(nextSegment, child);
previousSegment = nextSegment;
previousLevel = nextLevel;
nextLevel = nextLevel[nextSegment] as Dictionary<string, Object>;
var json = JsonConvert.SerializeObject(result, Formatting.Indented);