[OpenLayers-Users] OpenLayers.Format.JSON not working

Eric Lemoine eric.lemoine at camptocamp.com
Sat Nov 28 08:48:02 EST 2009


On Thursday, November 26, 2009, Mak Kolybabi <mak.kolybabi at telenium.ca> wrote:
> I've wasted long enough on this, it's time to ask for help...
>
> I'm making a simple Ajax request with OpenLayers.loadURL, which works perfectly.
> If I process the return data with:
>
>     var info = eval("(" + response.responseText + ")");
>
> a proper object is created in both IE and Firefox. But if I try to use:
>
>     var parser = new OpenLayers.Format.JSON();
>     var info = parser.read(response.responseText);
>
> nothing happens. In fact, if I try:
>
>     var parser = new OpenLayers.Format.JSON();
>     var info = parser.read("{'a': 1}");


This isn't valid JSON. Use <http://www.JSONLint.com/>. Try {"a": 1}.

Cheers,

-- 
Eric Lemoine

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 96
Mail : eric.lemoine at camptocamp.com
http://www.camptocamp.com



More information about the Users mailing list