Something liiike
import tables
type
Obj = ref object
children: Table[string, Obj]
value: string
proc newObj():Obj=
result = new Obj
result.children=initTable[string, Obj]()
proc newObj(key:string,kids:Obj=newObj()):Obj=
result = new Obj
result.children={key:kids}.toTable()
proc `[]=`(o:Obj,k:string,val:string)=
o.children[k].value=val
proc `[]`(o:Obj,k:string):Obj=
o.children[k]
var rootobj = newObj("me",newObj("location",newObj("city")))
rootobj["me"]["location"]["city"]="Toledo"
proc getField(parent:Obj,f:seq[string]):string=
if f.len==1:
return parent[f[0]].value
else:
return getField(parent[f[0]],f[1..^1])
echo getField(rootobj,@["me","location","city"])
Run