Skip to main content

Bug Tracker

Side navigation

#1529 closed bug (wontfix)

Opened August 23, 2007 11:30AM UTC

Closed September 18, 2007 02:04PM UTC

jquery conflicts with json library

Reported by: mkirst Owned by:
Priority: critical Milestone: 1.1.4
Component: core Version: 1.1.3
Keywords: Cc:
Blocked by: Blocking:
Description

When using jquery together with library json (from http://www.json.org/) it results in conflicts.

I've tested two different versions from json.

I've added sample files illustrating the bug.

Attachments (3)
  • crash.html (0.9 KB) - added by mkirst August 23, 2007 11:31AM UTC.

    sample html code

  • json-2006-11-09.js (4.0 KB) - added by mkirst August 23, 2007 11:31AM UTC.

    from json.org

  • json-2007-08-19.js (10.5 KB) - added by mkirst August 23, 2007 11:32AM UTC.

    from json.org

Change History (3)

Changed August 23, 2007 02:44PM UTC by aheimlich comment:1

Actually, it's the other way around. Crockford's JSON library conflicts with jQuery (and pretty much other library out there as well). The primary offender is Object.prototype.toJSONString, which completely screws up all of the for...in loops that jQuery uses![1].

There was a discussion about protecting jQuery from people who tamper with Object.prototype a long time ago, but the dev team decided against it (can't remember exactly why), so I doubt this will ever be "fixed". IIRC, though, people have posted versions of json.js that don't mess with Object.prototype to the mailing list, so you could do a search and see what you find.

![1] http://erik.eae.net/archives/2005/06/06/22.13.54

Changed August 23, 2007 05:39PM UTC by mkirst comment:2

Thanks for your quick help. So, better close this "bug" ;-)

As a matter of fact, I'm developing portlets for Liferay Enterprise Portal.

And as a portlet (JSR-168) I'm not allowed (or have any influence)

on the libraries use by the portal. So unfortunately I refactored

my code not to use jQuery.

But I will send the Liferay guys a message, hopefully the fix it in next versions.

Changed September 18, 2007 02:04PM UTC by brandon comment:3

resolution: → wontfix
status: newclosed

As already mentioned by aheimlich, the JSON library extends the Object's prototype. Unfortunately we cannot support the untold number of issues brought about by doing so.