From 2dd7764d2c2f715543c3b010ea5e62172a6fa3e5 Mon Sep 17 00:00:00 2001 From: thixpin Date: Mon, 20 Apr 2020 13:37:36 +0630 Subject: [PATCH 1/2] Add numericCheck option --- ImportJSON.gs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/ImportJSON.gs b/ImportJSON.gs index 731806e..453f8f2 100644 --- a/ImportJSON.gs +++ b/ImportJSON.gs @@ -54,11 +54,12 @@ * noHeaders: Don't include headers, only the data * allHeaders: Include all headers from the query parameter in the order they are listed * debugLocation: Prepend each value with the row & column it belongs in + * numericCheck: Change to numer format if possiable * * For example: * * =ImportJSON("http://gdata.youtube.com/feeds/api/standardfeeds/most_popular?v=2&alt=json", "/feed/entry/title,/feed/entry/content", - * "noInherit,noTruncate,rawHeaders") + * "noInherit,noTruncate,rawHeaders,numericCheck") * * @param {url} the URL to a public JSON feed * @param {query} a comma-separated list of paths to import. Any path starting with one of these paths gets imported. @@ -97,11 +98,12 @@ function ImportJSON(url, query, parseOptions) { * noHeaders: Don't include headers, only the data * allHeaders: Include all headers from the query parameter in the order they are listed * debugLocation: Prepend each value with the row & column it belongs in + * numericCheck: Change to numer format if possiable * * For example: * * =ImportJSON("http://gdata.youtube.com/feeds/api/standardfeeds/most_popular?v=2&alt=json", "user=bob&apikey=xxxx", - * "validateHttpsCertificates=false", "/feed/entry/title,/feed/entry/content", "noInherit,noTruncate,rawHeaders") + * "validateHttpsCertificates=false", "/feed/entry/title,/feed/entry/content", "noInherit,noTruncate,rawHeaders,numericCheck") * * @param {url} the URL to a public JSON feed * @param {payload} the content to pass with the POST request; usually a URL encoded list of parameters separated by ampersands @@ -155,6 +157,7 @@ function ImportJSONViaPost(url, payload, fetchOptions, query, parseOptions) { * noHeaders: Don't include headers, only the data * allHeaders: Include all headers from the query parameter in the order they are listed * debugLocation: Prepend each value with the row & column it belongs in + * numericCheck: Change to numer format if possiable * * For example: * @@ -516,6 +519,12 @@ function defaultTransform_(data, row, column, options) { if (hasOption_(options, "debugLocation")) { data[row][column] = "[" + row + "," + column + "]" + data[row][column]; } + + if (hasOption_(options, "numericCheck") && data[row][column] ){ + if(data[row][column].toString() == parseFloat(data[row][column])){ + data[row][column] = parseFloat(data[row][column]); + } + } } /** From e038618b157739812c47d8a11f562cb10be4145b Mon Sep 17 00:00:00 2001 From: thixpin Date: Mon, 20 Apr 2020 13:45:09 +0630 Subject: [PATCH 2/2] fixed spelling --- ImportJSON.gs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ImportJSON.gs b/ImportJSON.gs index 453f8f2..6f5d371 100644 --- a/ImportJSON.gs +++ b/ImportJSON.gs @@ -54,7 +54,7 @@ * noHeaders: Don't include headers, only the data * allHeaders: Include all headers from the query parameter in the order they are listed * debugLocation: Prepend each value with the row & column it belongs in - * numericCheck: Change to numer format if possiable + * numericCheck: Change to number format if possible * * For example: * @@ -98,7 +98,7 @@ function ImportJSON(url, query, parseOptions) { * noHeaders: Don't include headers, only the data * allHeaders: Include all headers from the query parameter in the order they are listed * debugLocation: Prepend each value with the row & column it belongs in - * numericCheck: Change to numer format if possiable + * numericCheck: Change to number format if possible * * For example: * @@ -157,7 +157,7 @@ function ImportJSONViaPost(url, payload, fetchOptions, query, parseOptions) { * noHeaders: Don't include headers, only the data * allHeaders: Include all headers from the query parameter in the order they are listed * debugLocation: Prepend each value with the row & column it belongs in - * numericCheck: Change to numer format if possiable + * numericCheck: Change to number format if possible * * For example: *