[OpenLayers-Users] Improving JSON support ( native and throwing/reporting errors )

Zac Spitzer zac.spitzer at gmail.com
Mon Jun 14 22:59:46 EDT 2010


Looking at format JSON.js file,  it's classic example of where OL fails silently

the code first runs a regex to validate the JSON, which returns null
if it doesn't validate
and then if it passes the initial validate and then crashes, it's also
wrapped in a try catch
which simples ignores any errors

what is the normal convention to report / throw errors in OL? Failing
silently is nasty

Also now that IE, FF and a few others have native JSON support, how does
everyone feel about conditionally using the native JSON when it's available

z




On 14 June 2010 22:43, Zac Spitzer <zac.spitzer at gmail.com> wrote:
> yup, i was using coldfusion's built in javascript escaping format,
> jsstringformat
>
> i have found an appropriate function for json encoding option on cflib.org
>
> thanks for you help
>
> On 14 June 2010 17:42, Moataz Elmasry <zaza1851983ml at googlemail.com> wrote:
>> I just tried your string with an online parser:
>> http://json.parser.online.fr/ and eval() returned an error.
>> You don't need to escape the single quote character since its inside a
>> double quote, so just remove the slash \ and it should work
>>
>>
>> Eric Lemoine wrote:
>>> On Fri, Jun 11, 2010 at 2:34 AM, Zac Spitzer <zac.spitzer at gmail.com> wrote:
>>>
>>>> Hi Eric,
>>>>
>>>> thanks for trying that.
>>>>
>>>> I have created a cut down test case which demonstrates the problem
>>>>
>>>> http://mapguide-central.ennoble.com.au/testcase/geo_json_escaping/testcase.html
>>>>
>>>> there are two vector layers, one which is escaped and one which isn't
>>>>
>>>> the escaped one is on by default and doesn't render
>>>>
>>>
>>> Ok.
>>>
>>> But why are you escaping quotes? From my understanding you should not,
>>> only certain characters can escaped (with "\"), and the quote
>>> character isn't one of them. See <http://json.org>.
>>>
>>>
>>>
>>
>> _______________________________________________
>> Users mailing list
>> Users at openlayers.org
>> http://openlayers.org/mailman/listinfo/users
>>
>
>
>
> --
> Zac Spitzer
> Solution Architect / Director
> Ennoble Consultancy Australia
> http://www.ennoble.com.au
> http://zacster.blogspot.com
> +61 405 847 168
>



-- 
Zac Spitzer
Solution Architect / Director
Ennoble Consultancy Australia
http://www.ennoble.com.au
http://zacster.blogspot.com
+61 405 847 168



More information about the Users mailing list