skip to Main Content

How can I get the value of a object in coffeescript:
{text=”mytext”, @name=”Jon”}

object.text works great but can`t get object.@name and is a 3party api json object (ebay api for example use a attribute name with @ for currency_Id), what can I do?

2

Answers


  1. You should be able to acceess properties like this:

    obj['@name']
    
    Login or Signup to reply.
  2. You can use what’s called 'Bracket notation'

    object['@name']
    

    You should use this method when: (taken from this answer)

    The property name contains characters not permitted in identifiers,
    e.g. starts with a digit†, or contains a space or dash (-), e.g.
    obj[“my property”].

    You can read up on the topic here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search