I've got a few spare minutes. So, code-review hat goes on.
var data = new Array();
data['__type'] = 'urn:inin.com:connection:icAuthConnectionRequestSettings';
data['applicationName'] = 'test';
data['userID'] = 'blah';
data['password'] = 'blah;
data['val-name'] = 'blah;
Firstly, I think you have some typographic errors in this code. The last two values have oddly paired quotes.
var data = new Array();
data['__type'] = 'urn:inin.com:connection:icAuthConnectionRequestSettings';
data['applicationName'] = 'test';
data['userID'] = 'blah';
data['password'] = 'blah';
data['val-name'] = 'blah';
Next, at the moment, you're assigning keys to an array. Which probably isn't what you mean (summary of the issue here; short version is that some collection methods will give you unexpected results). You likely mean to start an empty object as data
.
var data = {};
data['__type'] = 'urn:inin.com:connection:icAuthConnectionRequestSettings';
data['applicationName'] = 'test';
data['userID'] = 'blah';
data['password'] = 'blah';
data['val-name'] = 'blah';
Finally, you can use data literals in JS, rather than serial assignment.
var data = {
'__type': 'urn:inin.com:connection:icAuthConnectionRequestSettings',
'applicationName': 'test',
'userID': 'blah',
'password': 'blah',
'val-name': 'blah'
}
As part of this, you've created an object with a slot name that has a -
in it. There's nothing illegal about this, but it does prevent you from accessing that slot with dot notation.
console> data['val-name']
'blah'
console> data.val-name
NaN
That has nothing to do with the key being illegal, and everything to do with the access being parsed as a subtraction. That is, data.val-name
gets interpreted as "Subtract the value of name
from the value of data.val
" rather than "Access the slot val-name
of the object data
".