I have a flattened object that I need a subsection of. The below snippet is an example:
var raw = {
"Result[0].Row[0].GUID": "sdfsdfsd",
"Result[1].True": true,
"Result[1].Row[0].Name": "Item 1 name",
"Result[1].Row[0].Type": "3",
"Result[1].Row[0].Active": false,
"Result[1].Row[1].Name": "Item 2 name",
"Result[1].Row[1].Type": "7b",
"Result[1].Row[1].Active": true,
"Result[1].Row[2].Name": "Item 3 name",
"Result[1].Row[2].Type": "qr8",
"Result[1].Row[2].Active": true,
"Result[2].Row[0].Desc": "yaddayaddayadda"
}
I'm trying to clean up the formatting and I only want to deal with anything beginning with Result[1].Row
. Once I segregate that subsection, I then want to iterate over the rows, so something like...
var i = 0,
goodRows = [];
for (var row in "Result[1].Row Object") {
var cleanObj = {
name: row[i].Name,
type: row[i].Type,
active: row[i].Active
}
goodRows.push(cleanObj)
i++;
}
The issue I'm having is that I can't even come up with a clunky solution for this problem, much less a clean one. I'm definitely willing to use some third party library such as lodash, underscore, or anything with NPM.