Ignore part of the key in JSON attributes - Javascript JSon

Javascript examples for JSon:JSon Object

Description

Ignore part of the key in JSON attributes

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){/*from  w  w  w. java2  s.  co m*/
var a = [
{
  "attributes":{
  "my.act.halt":"1",
  "my.dyn.prop.current.profile":"1",
  "my.dyn.prop.myString":"1.0",
  }
}
]
var items = [];
for ( key in a[0].attributes) {
    if (key.match('.dyn.prop.myString')) {
       items.push(a[0].attributes[key])
    }
}
console.log(items)
    }

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials