<div dir="ltr">Hi,<br><br>If you are generating this information, check this part:<br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">{<br> "origin": "2013P00109",<br>
"type": "LJ",<br>
<b>"naf": "5610A",</b><br>
},<br></blockquote><div><div class="gmail_extra"><br></div><div class="gmail_extra">the final comma in the naf line shouldn't be there.<br><br></div><div class="gmail_extra">Regards,<br clear="all"></div><div class="gmail_extra">
<div>Ezequiel</div>
<br><br><div class="gmail_quote">2014-08-22 15:35 GMT-03:00 harko33 <span dir="ltr"><<a href="mailto:xhanrot@gmail.com" target="_blank">xhanrot@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
I'm trying to send a JSON file to my Node.js app via Protocol.HTTP. The file<br>
is correctly sent, but I can't access to an array. Here is the relevant code<br>
:<br>
<br>
Client side<br>
<br>
(...)<br>
var vectorProtocol = new OpenLayers.Protocol.HTTP({<br>
url: '/getcoords',<br>
format: vectorFormat,<br>
readWithPOST: true,<br>
params: {<br>
"code_company": "8501",<br>
"data_company": [<br>
{<br>
"origin": "2013P00109",<br>
"type": "LJ",<br>
"naf": "5610A",<br>
},<br>
{<br>
"origin": "2013P00110",<br>
"type": "FJ",<br>
"naf": "5481"<br>
}<br>
]<br>
}<br>
});<br>
(...)<br>
<br>
Server side, I try to build an array with only the "origin" field of my<br>
array "data_company":<br>
<br>
function getCoords(params, callback) {<br>
var arrOrigin = params.data_company.map(function(d) {<br>
return d.origin;<br>
});<br>
(...)<br>
}<br>
<br>
And I get this error :<br>
<br>
> TypeError: Object [object Object] has no method "map"<br>
<br>
It seems that my "data_company" is not recognized as an array but as an<br>
object. I tried to JSON.parse(params) before but I get another error :<br>
<br>
> SyntaxError: Unexpected token o<br>
<br>
Anyway, I'm stuck. Do you have any clue to help me to solve this ?<br>
<br>
Thanks<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://osgeo-org.1560.x6.nabble.com/Error-when-parsing-array-with-OpenLayers-and-Protocol-HTTP-tp5157904.html" target="_blank">http://osgeo-org.1560.x6.nabble.com/Error-when-parsing-array-with-OpenLayers-and-Protocol-HTTP-tp5157904.html</a><br>
Sent from the OpenLayers Users mailing list archive at Nabble.com.<br>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.osgeo.org">Users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/openlayers-users" target="_blank">http://lists.osgeo.org/mailman/listinfo/openlayers-users</a><br>
</blockquote></div><br></div></div></div>