Js takes the value of the changed object name

   let test = [
  {
    id: test,
    all: {
        "1_unq": [{
            "o": [
                ["test", "0"],
                ["test1", "2"]
            ],
            "name": "james"
        }],
    }
},{
    id: test,
    all: {
        "2_unq": [{
            "o": [
                ["test", "0"],
                ["test1", "2"]
            ],
            "name": "mm"
        }],
    }
}
];

the data looks like this

is mainly to take the value of n_unq in all, because the number before _ unq will change

so I can"t take it directly. I have to run for to find out if there is the word unq in all, and if so, send the value inside to the page to display

. The idea of

is to run for, then use the regular expression to look for unq in all, take the full name of unq when you find it, and then use the full name to get the value

.

now, after getting the full name of unq, the card cannot get the value inside

let getName = "1_unq" //
getName.o[0][1] //

maybe you can"t use variables

I wonder if you have any better practices?

Jul.06,2022

let getName = "1_unq" / / assume this is the full name taken

test [I] .all [getName] .o0


convert the object to a string, replace the key into a unified one, and then parse the object

.
Menu