ImportJSON icon indicating copy to clipboard operation
ImportJSON copied to clipboard

Logical true isn't recognized

Open GregE-369 opened this issue 5 years ago • 3 comments

values of true are output as text values while values of false are output as boolean values.

example file: https://data.ncaa.com/casablanca/scoreboard/football/fbs/2019/14/scoreboard.json

best regards, GregE

GregE-369 avatar Dec 08 '19 12:12 GregE-369

There definitely seems to be an issue with booleans. My experience is that values of true show up but false doesn't. However, I tried your sample and seemed to get mixed results. Still never saw a "false" value make it into the sheet.

ttrentham avatar Dec 23 '19 19:12 ttrentham

The issue seems to be in the defaultTransform_ function. In there, there is a block where values are automatically transformed into a string and cut to max 256 characters. To prevent this from happening, you can add the noTruncate option and/or modify that bit of code:

=importjson("https://data.ncaa.com/casablanca/scoreboard/football/fbs/2019/14/scoreboard.json";;"noTruncate")

Or replace:

if (!hasOption_(options, "noTruncate") && data[row][column]) {
      data[row][column] = data[row][column].toString().substr(0, 256);
  }

By:

if (!hasOption_(options, "noTruncate") && data[row][column]) {
    if ((typeof data[row][column]) === 'number' || (typeof data[row][column]) === 'boolean') {
      data[row][column] = data[row][column];
    } else {
      data[row][column] = data[row][column].toString().substr(0, 256);
    }
  }

krijnsent avatar Jan 06 '20 14:01 krijnsent

@krijnsent is correct 👍

This should be the default behavior in here.

milosmns avatar Aug 06 '21 14:08 milosmns