This project is archived and is in readonly mode.

#419 ✓resolved
Jan Kassens

Use the native JSON object if available

Reported by Jan Kassens | October 11th, 2008 @ 06:43 PM | in 2.0 (closed)

A nightly of Firefox introduced an native JSON object, for JSON parsing. We should be compatible with that and use the native parser if available.

Comments and changes to this ticket

  • Jan Kassens

    Jan Kassens October 11th, 2008 @ 06:44 PM

    • State changed from “new” to “open”
  • thomasd

    thomasd October 17th, 2008 @ 09:18 AM

    • Tag set to firefox3.1, json

    This is my fast fix, without using the native parser. Without that fix ff3.1b2pre throws an error: "redeclaration of const JSON" and the whole script breaks.

    I know, it's not very elegant, but it works: Instead of:

    var JSON = new Hash({
     //decleration of encode and decode

    Write this:

    if (JSON === undefined) {
            //I don't want to make JSON a global so I decided to write window.JSON
            //I think there isn't much difference, but I don't like globals
    	window.JSON = new Hash();
    $extend(JSON, {
     //decleration of encode and decode

    mootools 1.3 should support the native parser-methods, stringify and parse and use the native implementations if available as Jan already suggests.

  • thomasd

    thomasd October 17th, 2008 @ 10:23 AM

    • Tag changed from firefox3.1, json to firefox3.1, json

    A small fix to my previous post:

    if (JSON === undefined) {

    Should be:

    if (window['JSON'] === undefined) {

    or you get an "JSON is undefined" error.

  • Christoph Pojer

    Christoph Pojer March 13th, 2009 @ 12:43 PM

    • Assigned user changed from “Jan Kassens” to “Christoph Pojer”
  • Christoph Pojer

    Christoph Pojer March 22nd, 2009 @ 02:27 AM

    • Milestone changed from 1.2.3 to 2.0
    • State changed from “open” to “resolved”

    This will be added in the next major release of mootools at latest

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins