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.
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
Post a Comment