I'm trying to use _.findWhere to locate nodes that contain backslashes (they are indicating a 'sub folder' in an api). However i'm having an issue searching for a single backslash, and i'm not sure if this is just one of those things with the language that isn't easily possible. My function call currently looks like this:
for(var i in data){
if(
_.findWhere(data, {name:'\\'})
) {
console.log(data[i]);
console.log('this');
};
}
and an example of the data:
[
{
"name": "QA",
"matchedElements": [
{
"id": 285,
"name": " exch2010"
},
{
"id": 288,
"name": "ad01"
},
{
"id": 289,
"name": "exchange01"
},
{
"id": 290,
"name": "ad02"
}
]
},
{
"name": "QA\\Stuff",
"matchedElements": [
{
"id": 240,
"name": "build-vmstudio-26"
},
{
"id": 241,
"name": "build-seleniumw"
},
{
"id": 242,
"name": "build-linux-02"
},
{
"id": 250,
"name": "build-rh5-x64"
},
{
"id": 251,
"name": "build-rh5-x86"
},
{
"id": 563,
"name": "build-linux-01"
}
]
},
{
"name": "PROD",
"matchedElements": [
{
"id": 7,
"name": "css-ora11sql2k8.uptimesoftware.com"
},
{
"id": 8,
"name": "css-sql2005.uptimesoftware.com"
}
]
}
]
Eventually the script will take the node with the double back slash, match it with a node of the same name and place it as a sub node to create a nested object.