From 8d11dc6950eafc7d01f141ce91d4f585caa29f3b Mon Sep 17 00:00:00 2001 From: Douglas Crockford Date: Wed, 8 Dec 2010 01:24:13 -0800 Subject: [PATCH] Create a JSON object only if one does not already exist. --- json.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/json.js b/json.js index 15ebda6..ea2377f 100755 --- a/json.js +++ b/json.js @@ -1,6 +1,6 @@ /* json.js - 2010-11-18 + 2010-12-08 Public Domain @@ -193,6 +193,13 @@ */ +// Create a JSON object only if one does not already exist. We create the +// methods in a closure to avoid creating global variables. + +if (!this.JSON) { + this.JSON = {}; +} + (function () { "use strict";