It's puzzling why I'm finding this challenging. It seems like there should be a solution using Lodash or a similar tool.
My object is structured like this:
{ "fdjkafdajkfasfjkdaslj": {
"-LMUD-2APhiSLkEtVbM": {
"profileName": "bob",
"profilePic": "www.profilepic.com",
"score": 73,
"teamName": "lzs"
}
}
}
I won't know the first two keys in the structure, like "fdjkafdajkfasfjkdaslj"
or "-LMUD-2APhiSLkEtVbM"
.
All I need to do is extract these key values and store them in an array.
"profileName": "bob",
"profilePic": "www.profilepic.com",
"score": 73,
"teamName": "lzs"
What would be the best approach to achieve this in JavaScript (specifically React.js)? I thought about using Lodash but haven't found a suitable solution yet. Most of my searches for extracting nested Key/Value data from JSON suggest using a path, but in this case, I don't have that information. The only certainty I have is the consistent object structure with two unknown keys preceding the actual key/value data.