I am creating a web app in order to do a json builder. The problem is I have the json in javascript and I have a string with the position of the element to change.

For me it's easy to access to it doing for loops, but the goal is update or delete the field or array.

The only success solution I have found, it's an switch with the possibles splited trace array lengths.

Json example:

```
{
    "name" : "Marcelino"
    "id" : "${id}"
    "poderes":
    {
        "poder1" : "volar"
        "poder2" : "echar fuego"
        "poder3" : "${poder4}"
        "array":
        {
             "Elemento1" : "adada"
        }
    } 
}

```

I want to modify the following key:value pair:

```
"poderes" : "volar" 

```

I have the trace in a variable:

```
trace = poderes-poder1

```

The current solution

```
...
let traceArray = trace.split("-");
...
switch(traceArray.length){
...
case1:
    json[traceArray[0]]
...
case2:
    json[traceArray[0]][traceArray[1]]
...
case3:
    json[traceArray[0]][traceArray[1]][traceArray[2]]
...

```

Looking for better solution.

Thanks so much for the help.