[OpenLayers-Dev] native JSON

Andreas Hocevar ahocevar at opengeo.org
Thu Feb 17 05:04:40 EST 2011


Hi Slawomir,

you must be doing something wrong when serializing. OpenLayers.Format.GeoJSON::write takes an array of features as argument. I just verified that it works as expected if you use it this ways.

It looks like you are serializing your arrays separately in some way. Maybe you can share your code to shed some light on what you're doing?

Regards,
Andreas.

On Feb 17, 2011, at 09:07 , Slawomir Messner wrote:

> Hi,
> some revisions ago the JSON.js is changed to use the native browser possibilities. But now arrays are in double quotes(see example below) and our backend has problems with deserialize it. As I know it is that the JSON format has no double quotes around arrays. So where is the error, is the native serializer(Firefox and Chrome) not producing a standard format? With the old code (before native browser function is used) all was fine.
> The object we pass to the OL.Format.JSON.write has the features-attribute as array I tested it in firebug/chrome-dev-tools. I don't know why it should be a string after serializing.
> 
> Example:
> {"type":"FeatureCollection","properties":{},"defaultStyle":{"pointRadius":"4","fillColor":"#008700","fillOpacity":"0.6","stroke":"True","strokeColor":"#21007E","strokeOpacity":"0.9","strokeWidth":"1","strokeDashstyle":"solid","label":"","fontFamily":"Arial","labelAlign":"lb","display":""},
> 
> "features":"[{\"type\": \"Feature\", \"id\": \"OpenLayers.Feature.Vector_339\", \"properties\": {\"gid\": 101225, \"title\": \"VREDEN\", \"ownerType\": 1, \"style\": {\"label\": \"<font color='#FF0000' bold='false' italic='false' sizeFactor='1' >[Â</font>\", \"fontFamily\": \"SprachGIS-Symbole2\"}, \"symbols\": [26373, 26367], \"wktGeometry\": \"POINT(759321.378649999 6806065.527048201)\"}, \"geometry\": {\"type\": \"Point\", \"coordinates\": [759321.378649999, 6806065.527048201]}}, {\"type\": \"Feature\", \"id\": \"OpenLayers.Feature.Vector_341\", \"properties\": {\"gid\": 101252, \"title\": \"MILLINGEN\", \"ownerType\": 1, \"style\": {\"label\": \"<font color='#FF0000' bold='false' italic='false' sizeFactor='1' >Â</font>\"...
> Has someone the same experience?
> Thanks for help in advance.
> Slawomir
> 
> _______________________________________________
> Dev mailing list
> Dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-dev



-- 
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.



More information about the Dev mailing list