From cf23d0541cfe4875c9dcd6fe182a40f5c567b19d Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Mon, 29 Feb 2016 16:19:30 +0100 Subject: [PATCH] Get rid of goog.json Use JSON.parse and JSON.stringify instead. --- config/example.json | 1 - config/examples-all.json | 1 - config/ol.json | 1 - doc/tutorials/closure.md | 2 -- doc/tutorials/custom-builds.md | 1 - src/ol/format/jsonfeatureformat.js | 17 +++++++---------- test/index.html | 2 -- 7 files changed, 7 insertions(+), 18 deletions(-) diff --git a/config/example.json b/config/example.json index bf4c36b8ad..5ed49aa7da 100644 --- a/config/example.json +++ b/config/example.json @@ -25,7 +25,6 @@ ], "define": [ "goog.dom.ASSUME_STANDARDS_MODE=true", - "goog.json.USE_NATIVE_JSON=true", "goog.DEBUG=false" ], "jscomp_error": [ diff --git a/config/examples-all.json b/config/examples-all.json index 9fa8cad268..fb3c2d2874 100644 --- a/config/examples-all.json +++ b/config/examples-all.json @@ -26,7 +26,6 @@ ], "define": [ "goog.dom.ASSUME_STANDARDS_MODE=true", - "goog.json.USE_NATIVE_JSON=true", "goog.DEBUG=false" ], "jscomp_error": [ diff --git a/config/ol.json b/config/ol.json index a8c00a16e1..1a4071d6a0 100644 --- a/config/ol.json +++ b/config/ol.json @@ -15,7 +15,6 @@ ], "define": [ "goog.dom.ASSUME_STANDARDS_MODE=true", - "goog.json.USE_NATIVE_JSON=true", "goog.DEBUG=false" ], "jscomp_error": [ diff --git a/doc/tutorials/closure.md b/doc/tutorials/closure.md index a964a5a2c2..80476bccaa 100644 --- a/doc/tutorials/closure.md +++ b/doc/tutorials/closure.md @@ -168,7 +168,6 @@ The minimum config file looks like this: ], "define": [ "goog.dom.ASSUME_STANDARDS_MODE=true", - "goog.json.USE_NATIVE_JSON=true", "goog.DEBUG=false", "ol.ENABLE_DOM=false", "ol.ENABLE_WEBGL=false" @@ -223,7 +222,6 @@ Here is a version of `config.json` with more compilation checks enabled: ], "define": [ "goog.dom.ASSUME_STANDARDS_MODE=true", - "goog.json.USE_NATIVE_JSON=true", "goog.DEBUG=false", "ol.ENABLE_DOM=false", "ol.ENABLE_WEBGL=false" diff --git a/doc/tutorials/custom-builds.md b/doc/tutorials/custom-builds.md index 202382a898..86b4d94613 100644 --- a/doc/tutorials/custom-builds.md +++ b/doc/tutorials/custom-builds.md @@ -61,7 +61,6 @@ Creating a custom build requires writing a build configuration file. The format ], "define": [ "goog.dom.ASSUME_STANDARDS_MODE=true", - "goog.json.USE_NATIVE_JSON=true", "goog.DEBUG=false" ], "jscomp_off": [ diff --git a/src/ol/format/jsonfeatureformat.js b/src/ol/format/jsonfeatureformat.js index 331d41409c..14f704eb73 100644 --- a/src/ol/format/jsonfeatureformat.js +++ b/src/ol/format/jsonfeatureformat.js @@ -1,7 +1,6 @@ goog.provide('ol.format.JSONFeature'); goog.require('goog.asserts'); -goog.require('goog.json'); goog.require('ol.format.Feature'); goog.require('ol.format.FormatType'); @@ -30,8 +29,8 @@ ol.format.JSONFeature.prototype.getObject_ = function(source) { if (goog.isObject(source)) { return source; } else if (typeof source === 'string') { - var object = goog.json.parse(source); - return object ? object : null; + var object = JSON.parse(source); + return object ? /** @type {Object} */ (object) : null; } else { goog.asserts.fail(); return null; @@ -121,7 +120,7 @@ ol.format.JSONFeature.prototype.readProjectionFromObject = goog.abstractMethod; * @inheritDoc */ ol.format.JSONFeature.prototype.writeFeature = function(feature, opt_options) { - return goog.json.serialize(this.writeFeatureObject(feature, opt_options)); + return JSON.stringify(this.writeFeatureObject(feature, opt_options)); }; @@ -136,9 +135,8 @@ ol.format.JSONFeature.prototype.writeFeatureObject = goog.abstractMethod; /** * @inheritDoc */ -ol.format.JSONFeature.prototype.writeFeatures = function( - features, opt_options) { - return goog.json.serialize(this.writeFeaturesObject(features, opt_options)); +ol.format.JSONFeature.prototype.writeFeatures = function(features, opt_options) { + return JSON.stringify(this.writeFeaturesObject(features, opt_options)); }; @@ -153,9 +151,8 @@ ol.format.JSONFeature.prototype.writeFeaturesObject = goog.abstractMethod; /** * @inheritDoc */ -ol.format.JSONFeature.prototype.writeGeometry = function( - geometry, opt_options) { - return goog.json.serialize(this.writeGeometryObject(geometry, opt_options)); +ol.format.JSONFeature.prototype.writeGeometry = function(geometry, opt_options) { + return JSON.stringify(this.writeGeometryObject(geometry, opt_options)); }; diff --git a/test/index.html b/test/index.html index 52bae4e97d..3d461b2021 100644 --- a/test/index.html +++ b/test/index.html @@ -31,8 +31,6 @@