user565993
user565993

Reputation:

How can I access JSON.@attribute from an XML Converted on Javascript

I got a JSON converted from XML.

So, how can I get [email protected].

@ <-- this one will make javascript error

I use Javascript.

Upvotes: 0

Views: 2395

Answers (1)

&#193;lvaro Gonz&#225;lez
&#193;lvaro Gonz&#225;lez

Reputation: 146510

Making a great exercise of imagination, I suppose you've used jQuery to download some JSON through AJAX and you have an object with a key called "@attribute", such as this:

var foo = {
    "@attribute": 33
}

You just need to use square brackets:

console.log(foo["@attribute"])

Upvotes: 2

Related Questions