javascript - jQuery JSON value -


i have rest service returns json this:

[{"@id":"123","name":"name"}] 

and i'm tearing hair out trying figure out how hell value @id. i've tried:

var temp =  data['@id']; var temp = data[0].'@id'; var temp = data[0].['@id']; 

all of return errors. can please me out here?

var temp = data[0]['@id'];

using .property accepts symbols can use in identifiers , identical ["property"]. since have array single object "@id" property , @ can't used in identifiers, have use brackets. above translates data -> it's 0th index (index count start 0) -> property "@id".


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -