I\'m working with JSON for the first time, so please excuse my lack of knowledge.
I\'m trying to use a JSON file to populate data in a Google Sheet. I just don\'t k
How about this workaround?
When I saw the URL of https://eddb.io/archive/v6/bodies_recently.jsonl
, I noticed that the extension of the file is jsonl
. So when I checked the values retrieved from https://eddb.io/archive/v6/bodies_recently.jsonl
, it was found that the values were JSON Lines. This has already been mentioned by Dimu Designs's comment. Also I could confirm that the official document says bodies_recently.jsonl
is Line-delimited JSON.
Unfortunately, ImportJSON cannot directly parse the values of JSON Lines. So it is required to modify the script as a workaround. In your shared Spreadsheet, the script of ImportJSON is put as the container-bound script. In this modification, I modified the script. Please modify as follows.
The following function can be seen at the line of 130 - 135 in your script editor.
function ImportJSONAdvanced(url, query, options, includeFunc, transformFunc) {
var jsondata = UrlFetchApp.fetch(url);
var object = JSON.parse(jsondata.getContentText());
return parseJSONObject_(object, query, options, includeFunc, transformFunc);
}
Please replace the above function to the following script, and save the script. Then, please put =ImportJSON("https://eddb.io/archive/v6/bodies_recently.jsonl", "/id")
to a cell, again.
function ImportJSONAdvanced(url, query, options, includeFunc, transformFunc) {
var jsondata = UrlFetchApp.fetch(url);
var object = jsondata.getContentText().match(/{[\w\s\S].+}/g).map(function(e) {return JSON.parse(e)}); // Modified
return parseJSONObject_(object, query, options, includeFunc, transformFunc);
}
https://eddb.io/archive/v6/bodies_recently.jsonl
, I'm not sure whether this modified script works for all JSON lines values. I apologize for this.If I misunderstood your question and this was not the result you want, I apologize.