JSFiddle - React, Tailwind, and code Playground
by ajo4you
JavaScript
var a = [{
"attributes": {
"examplePrefixToSkipOver.act.halt": "1",
"examplePrefixToSkipOver.dyn.prop.current.profile": "1",
"examplePrefixToSkipOver.dyn.prop.firmware": "1.0",
"examplePrefixToSkipOver.dyn.prop.ip.address.3g": "192.168.1.1",
"examplePrefixToSkipOver.dyn.prop.ip.address.cloud.com": "192.168.1.1",
"examplePrefixToSkipOver.dyn.prop.ip.address.lan": "10.0.0.1",
"examplePrefixToSkipOver.dyn.prop.ip.address.wifi": "192.168.1.1",
"examplePrefixToSkipOver.dyn.prop.location": "Chicago Office",
"examplePrefixToSkipOver.dyn.prop.name": "examplePrefixToSkipOver",
"examplePrefixToSkipOver.dyn.prop.current.prof": "1",
"examplePrefixToSkipOver.dyn.prop.status.detail": "Placeholder-Text",
"examplePrefixToSkipOver.dyn.prop.timestamp": "2010-01-01T12:00:00Z"
}
}];
var items = [];
/*for ( key in a[0].attributes) {
if (key.match('.dyn.prop.firmware')) {
items.push(a[0].attributes[key])
}
}
console.log(items)*/
var value = 'examplePrefixToSkipOver.dyn.prop.current.profile';
var mam = 'dyn.prop.current.profile';
var selector = new RegExp('dyn.prop.current.prof');
var val = selector.test(value);
console.log(a[0].attributes[value]);
$.each(a[0].attributes['examplePrefixToSkipOver.dyn.prop.current.profile'], function (key, val) {
console.log(val);
items.push(val);
});
console.log(items);