Export JSON from json package.

Make sure to use the built-in JSON if it exists.

Fixes #1204.
This commit is contained in:
David Glasser
2013-08-02 11:19:08 -07:00
parent af5efd2996
commit e712d78cfb
2 changed files with 7 additions and 2 deletions

View File

@@ -0,0 +1,3 @@
// Do we already have a global JSON object? Export it as our JSON object.
if (window.JSON)
JSON = window.JSON;

View File

@@ -3,10 +3,12 @@ Package.describe({
internal: true
});
// We need to figure out how to serve this file only to browsers that
// don't have JSON.stringify (eg, IE7 and earlier -- or is that IE8?)
// We need to figure out how to serve this file only to browsers that don't have
// JSON.stringify (eg, IE7 and earlier, and IE8 outside of "standards mode")
Package.on_use(function (api) {
// Node always has JSON; we only need this in some browsers.
api.export('JSON', 'client');
api.add_files('json_native.js', 'client');
api.add_files('json2.js', 'client');
});