1

So I'm getting some JSON data containing 12 objects. outputting the objects to console shows me:

Object{ (...) }
  @categoryID: "123"
  @id: "234"
  categoryTitle: "abc"
  (...)

If I want to fetch the category title, I simply do item.categoryTitle. But if I want the ID, I can't use item.id.

According to this answer, one can use $object->{'@id'};, but trying $item->{'@id'} is not working.

So how to I get this value?

Community
  • 1
  • 1
Steven
  • 19,224
  • 47
  • 152
  • 257

1 Answers1

3

Refer it using ['key'] syntax

var obj = { '@id' : 123 };
console.log(obj['@id']);   //123
rajuGT
  • 6,224
  • 2
  • 26
  • 44