Jquery – Json JQuery conflict

jqueryjson

Our enterprise app currently uses Json.js I downloaded the JQuery js file, included it in a page that uses json and I started getting Javascript errors in the json.js file. The error is:

Microsoft JScript runtime error: Object doesnt suppor this propety or method

Is this a known issue?

EDIT:
I am not sure where this json.js file was downloaded from (a coworker had done this). However, the json.js looks like this:

    json.js
2007-04-13

Public Domain

This file adds these methods to JavaScript:

    array.toJSONString()
    boolean.toJSONString()
    date.toJSONString()
    number.toJSONString()
    object.toJSONString()
    string.toJSONString()

I replaced this file with json2.js and it appears that the new file does not have parseJSON() function. We use this function in several pages.

Best Answer

Looks as though Json.js does use $ as a variable name. In these cases you need to use JQuery's noconflict function. Basically you have to put the JQuery script tag above the Json script tag and call noconflict on jquery before the Json library gets loaded. One nice feature is that, while noconflict make JQuery not use the $, you can assign the results of noconflict (which will be the JQuery object) to another alias, like so

var $j = jQuery.noConflict();

Now you just use $j anywhere you would have used $.