Bug Tracker

Opened 14 years ago

Closed 13 years ago

#1529 closed bug (wontfix)

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:


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 (928 bytes) - added by mkirst 14 years ago.
sample html code
json-2006-11-09.js (4.0 KB) - added by mkirst 14 years ago.
from json.org
json-2007-08-19.js (10.5 KB) - added by mkirst 14 years ago.
from json.org

Download all attachments as: .zip

Change History (6)

Changed 14 years ago by mkirst

Attachment: crash.html added

sample html code

Changed 14 years ago by mkirst

Attachment: json-2006-11-09.js added

from json.org

Changed 14 years ago by mkirst

Attachment: json-2007-08-19.js added

from json.org

comment:1 Changed 14 years ago by aheimlich

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

comment:2 in reply to:  1 Changed 14 years ago by mkirst

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.

comment:3 Changed 13 years ago by brandon

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.

Note: See TracTickets for help on using tickets.