Monday, April 26, 2010

JQuery 1.4 Brings Stricter JSON Parsing

JQuery 1.4 brings stricter JSON (JavaScript Object Notation) parsing with the new release. If you are suddenly having problems (namely, 'parseerror') with your JQuery powered ajax operations, this might be the culprit. Many people rely on Google's API hosting for their JQuery, which might mean they have been upgraded and not even know it.

I found that having a decent JSON parser during development really helped me isolate the problems. In my case,  my GTD application My Web Brain started having problems, and my template-based approach to JSON rendering made it quite difficult to see my JSON as it would look on the client. Using an online tool like Online JSON Parser really helped.

That fixed my problem. Having thought it over, however, I decided that my application had no business trying to render JSON on its own, and I switched to Simplejson for JSON encoding, which means I have one less problem to think about. The fact that Google App Engine's python environment includes Simplejson made the decision that much easier.

Of course, If you want to continue crafting JSON by hand, the specification might help.

No comments:

Post a Comment