I am analyzing information within a Google Sheet through Google App Script, through the active total range of the Google Sheet I obtain a javascript object of type multidimensional I transform this into a JSON object with the function JSON.stringify(miObjetoMultidimensional)
.
I get an object that in turn is full of empty values, and I try multiple ways to eliminate them from my object because I do not need them but I can not succeed.
I understand that Google AppScript runs on Rhino so I can not execute functions Arrows available in ES6.
This is a part of the object obtained at the output of the function.
[
[
"asm-tree.jar",
"",
"",
"commons-beanutils.jar",
"",
"",
"commons-collections.jar",
"",
"",
"util-java.jar",
"",
"",
"bcprov-jdk14-1.38.jar",
"",
"",
""
],
[
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
""
],
[
"\nDependencies",
"",
"",
"\nDependencies",
"",
"",
"\nDependencies",
"",
"",
"\nDependencies",
"",
"",
"\nDependencies",
"",
"",
"\nDependencies"
],
[
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
""
]
]
Try passing a function to validate the data within the same JSON.stringify()
but the fields kept appearing empty.
I add my current function.
function listValues() {
var activeSheet = SpreadsheetApp.getActiveSheet();
var dataRange = activeSheet.getDataRange();
var data = dataRange.getValues();
var json = JSON.stringify(data,function(key, value) {
if (value === '') {
return null;
}
return value;
});
SpreadsheetApp.getUi().alert(json);
}