Shannon -jj Behrens wrote:
> On 5/29/07, Ian Bicking <[EMAIL PROTECTED]> wrote:
>> [EMAIL PROTECTED] wrote:
>> > Dear Ian
>> >
>> > I just tried this on windows with waitforit rev 6599 (as well as ver 
>> 0.2
>> > from pypi) and I'm getting a unterminated string error at line 52:
>> > (sorry I've not tested this on my linux box I will later and let you
>> > know if I get the same error)
>> >
>> > dummy={"
>>
>> Is this on IE or Firefox?
>>
>> I'm a little fuzzy on how to handle JSON.  I thought simply
>> eval(req.responseText) would work, but it doesn't.  I tried
>> eval("dummy="+req.responseText) and that works, sometimes.  Not always,
>> apparently.
>>
>> I just committed what MochiKit does for evaluation.  I don't actually
>> understand how it would change anything, but maybe.  Another possibility
>> is that markup is actually being returned.  In the trunk I also improved
>> the error messages a little bit; you should now see the bad JSON code in
>> an error message in the page.
> 
> Using eval on JSON is generally considered bad practice.  There's some
> "evaluateJSON" function or something like that.  That way you can make
> sure you're getting data instead of evaluating code.

evaluateJSON just does an eval; at least it does in MochiKit.  It also 
seems to do something with comments, which I don't understand.  I've 
copied over what MochiKit does, it's not very complicated and I trust it 
as correct as it gets.

-- 
Ian Bicking | [EMAIL PROTECTED] | http://blog.ianbicking.org
             | Write code, do good | http://topp.openplans.org/careers

_______________________________________________
Paste-users mailing list
[email protected]
http://webwareforpython.org/cgi-bin/mailman/listinfo/paste-users

Reply via email to