javascript can't get object property value -


i have javascript object below:

var row = {               'fileattribute' : {                   '.\k\ar- #%i\.n/a': true,                   'size': '2040',                   'type' : 'pdf'                   }     }; 

but when try value of row.fileattribute['.\k\ar- #%i.n/a'] , undefined instead of true.

i know it's beacuse property name contains special characters. row.fileattribute.hasownproperty('.\k\ar- #%i.n/a') returns false.

i tried extract property values _.values(row.fileattribute['.\k\ar- #%i.n/a']) , got empty array.

my console: enter image description here

here example of issue:

http://jsfiddle.net/fvu2pqzz/8/

i appreciate help, thanks!

you need use bracket notation

console.info(row.entity.fileattribute['.kar- #%i.n/a']); 

var row = {              'entity' : {                  'fileattribute' : {                      '.\k\ar- #%i\.n/a': true,                      'size': '20',                      'qty' : '50'                  },                  'part2' : {                      'name': 'part 2',                      'size': '15',                      'qty' : '60'                  }              }          };            console.info(row.entity.fileattribute['.kar- #%i.n/a']);


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -