javascriptobjectspecial-charactersdecoratorreserved

how to escape @ in javascript or how to retrieve data from a field containing @


I am retrieving data from an API and one of the fields in the object it returns is @timestamp. When ever I try to parse this data like item.@timestamp javascript throws an error because the @ symbol is reserved as a decorator. How can I retrieve data from a field that is using a reserved character?


Solution

  • Use item['@timestamp'] instead of item.@timestamp.