Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions ImportJSON.gs
Original file line number Diff line number Diff line change
Expand Up @@ -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 number format if possible
*
* 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.
Expand Down Expand Up @@ -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 number format if possible
*
* 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
Expand Down Expand Up @@ -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 number format if possible
*
* For example:
*
Expand Down Expand Up @@ -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]);
}
}
}

/**
Expand Down