我有java脚本对象,我想从对象获取值,但我无法从对象中获取值。
这是我的javascript对象
var profile = { '[Profile ID]': 135675302,
'[Name | Prefix]': '',
'[Name | First]': 'KK',
'[Name | Middle]': '',
'[Name | Last]': 'Test',
'[Contact Name]': 'KK Test',
'[Email | Primary]': 'kk@yopmail.com',
'[Email | Main]': 'kk@yopmail.com',
'[Address | Primary | Line 1]': '',
'[Address | Primary | Line 2]': '',
'[Address | Primary | City]': '',
'[Address | Primary | State]': '',
'[Address | Primary | Zip]': '',
'[Address | Primary | Country]': '',
'[Address | Main | Line 1]': '',
'[Address | Main | Line 2]': '',
'[Address | Main | City]': '',
'[Address | Main | State]': '',
'[Address | Main | Zip]': '',
'[Address | Main | Country]': '',
'[Phone | Primary]': '',
'[Organization]': '',
'*Key Contact': '',
Facebook: '',
'Gender Served': [],
LinkedIn: '',
'School Size': [],
'School Website': '',
'Student Residential Status': [],
Title: '',
Twitter: '',
'[Created Date]': '05/11/2018 11:49:56 AM',
'[Expiration Date]': '',
'[Group]': [ 'Members' ],
'[Last Modified Date]': '05/11/2018 11:49:56 AM',
'[Member Status]': 'Active',
'[Member Type]': 'Members',
'[Username]': 'kk@yopmail.com' }
我想获取"名字","姓氏"和"用户名"从对象。
任何想法?
答案 0 :(得分:2)
如果无法使用点表示法访问属性值,请使用括号表示法 - 只需将属性值放在括号内的字符串中:
.result

答案 1 :(得分:1)
像这样:
var Username = Profile["[Username]"];
var First_name = Profile["[Name | First]"];
var Last_name = Profile["[Name | Last]"];