accessing namespaced object properties in javascript -
[updated]
given object:
var node = { 'comments': 'http://example.com/post/#comments', 'slash:comments': '143', }
one can access 'title' parameter using indexed access or dot notation:
node["comments"] // 'http://example.com/post/#comments' node.comments // 'http://example.com/post/#comments'
but namespaced property, indexed access available:
node["slash:comments"] // '143' node.slash:comments // javascript syntax error
is there way in javascript access namespaced property using dot notation?
it seems incongruous property keys can string value when using associative array access limited variable name syntax when using dot notation - there w3c spec defining this?
[update]
why @bergi? above object segment of object generated xml json library following xml (rss2.0 feed format):
<slash:comments>143</slash:comments> <comments>http://example.com/post/#comments</comments>
another library generates object, properties can accessed via dot notation.
'comments': [ 'http://example.com/post/#comments', { '__prefix': 'slash', '__text': '143' } ]
does know if there effort standardize transformations of xml json? used or acceptable library?
it's true, must follow js dot notation format. in case:
var node = { 'comments': 'http://example.com/post/#comments', 'slash':{ comments': '143' } } console.log(node.slash.comments);
the closest find documentation http://www.w3.org/wiki/objects_in_javascript
Comments
Post a Comment