I have this JSON:
{
"San Jose" : {
"Moravia" : {
"San Vicente" : "san_vicente",
"La Trinidad" : "la_trinidad",
"Los Colegios" : "los_colegios"
},
"Desamparados" : {
"San Miguel" : "san_miguel",
"Gravilias" : "gravilias",
"Damas" : "damas"
},
"Curridabat" : {
"Granadilla" : "granadilla",
"Sanchez" : "sanchez",
"Tirrases" : "tirrases"
}
},
"Cartago" : {
"Oreamuno" : {
"Cot" : "cot",
"Cipreses" : "cipreses",
"Santa Rosa" : "santa_rosa"
},
"La Union" : {
"Tres Rios" : "tres_rios",
"Dulce Nombre" : "dulce_nombre",
"Concepcion" : "concepcion"
},
"Turrialba" : {
"La Suiza" : "la_suiza",
"Peralta" : "peralta",
"La Isabel" : "la_isabel"
}
},
"Puntarenas" : {
"Golfito" : {
"Puerto Jimenez" : "puerto_jimenez",
"Guaycara" : "guaycara",
"Pavon" : "pavon"
},
"Coto Brus" : {
"San Vito" : "san_vito",
"Limoncito" : "limoncito",
"Agua Buena" : "agua_buena"
},
"Corredores" : {
"La Cuesta" : "la_cuesta",
"Paso Canoas" : "paso_canoas",
"Laurel" : "laurel"
}
}
}
And I want to get a certain value and his corresponding parent/child. For example:
var value = json.get("Cot");
var child = value.child();
Or:
var value = json.get("Cot");
var parent = value.parent();
Where var value = json.get("Cot");
is a reference to this value in the JSON object and value.child();/value.parent();
is a reference to his corresponding child(children)/parent(s).
Note: This must work no matter the size of the JSON and his dimensions. For example:
{
"val1" : {
"val2" : {
"val3" : {
"valX"
}
}
}
}