Question

I have created a json object from ruby with cobravsmongoose, however the attributes have the @ symbol in front of them. Whenever I try to access them with standard object notation in JavaScript, such as object.object.object.@attribute I get a parse error. Is there another way to access these objects?

Was it helpful?

Solution

Grab your JSON as a string instead. Do a replace to clean up the @ symbols, and recreate it as JSON.

OTHER TIPS

You can also access your object attributes with subscript notation:

object.object['@attribute']

But it's better to do as @Diodeus proposed

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top