I know little about JS, still learning big time. However I am writing a NodeJS app that offers JSON web services to a Angular Frontend.
One problem I have is sometimes my objects have flat name/value pairs and sometimes my objects values will show up in Chromes Console as "address:Array[1]". While I can always do address[0] to get a value, there are parts of my code where I have both that and address: "12345" not sure how to handle it.
I would think it best to have all data output the same way but I cant seem to factor my node code to dump out flat name/value. Nor do I know how to create a Array[1] for a value.
This is the code that creates Array[1] values instead of flat name/value
json.nodes.node.forEach(function (rowData) {
dataObject.push({
name: rowData.name
,address: rowData.address
,enabled: rowData.enabled
})
})
This is the code that creates the flat name/value pairs
for (i = 60; i < 85; i++) {
dataObject.push({
name: i + "f"
,address: i
,enabled: true
})
Any help would be great! Thanks in advance!