As a java developer transitioning to JavaScript, I'm faced with the task of parsing a JSON string retrieved from a WebService. Here is the JSON String:
{
"myArrayList": [
{
"myHashMap": {
"firstName": "Clara",
"name": "Housing and Community Development"
}
},
{
"myHashMap": {
"firstName": "Nick",
"name": "Housing and Community Development"
}
}
]
}
I've attempted to parse the data using the provided code snippet but keep getting 'undefined' as an alert message. The webservice sends the text in the specified format as a string.
$.getJSON("http://localhost:7001/WS/Users?Id=35",
function (jsonData)
{
for (var counter in jsonData.myArrayList) {
alert(jsonData.myArrayList[counter]['name'])
}
});
Unfortunately, the generated alert always shows 'undefined'. Any assistance in resolving this issue would be greatly appreciated. Thank you!