How and/or in which conventions are XML attributes put in an object named "@attributes" when converting XML to JSON? This style is used in this generic XML parser:
obj["@attributes"] = {};
for (var j = 0; j < xml.attributes.length; j++) {
var attribute = xml.attributes.item(j);
obj["@attributes"][attribute.nodeName] = attribute.nodeValue;
}
..to create JSON like this:
...
elem_array = [
{
"@attributes": {
an-attribute: "",
another-one: "mr.text"
}
}
]
...
I'm not looking for answers about element-centric vs. attribute-centric XML design, unless those things are more closely related to my question than I thought of course. ;)
Where did the @attributes notation come from and are there reasons to use it over using your own notation?
Thanks!