I am trying to send an array to google script to put into google sheets.
What I have for the google script:
function insert(e, sheet) {
//var scannedData = e.parameter.sOrder;
var scannedData = JSON.parse(e.parameter.sOrder);
var orderLocation = e.parameter.sLocation;
var d = new Date();
var ctime = d.toLocaleString();
sheet.appendRow([scannedData, orderLocation, ctime]);
return ContentService
.createTextOutput("Success")
.setMimeType(ContentService.MimeType.JAVASCRIPT);
}
the results it gives me is:
[Ljava.lang.Object;@5c0b25d1 Shipping 25/07/2020, 22:32:21
what it should give me is:
0152502243 Shipping 24/07/2020, 18:20:37
my code on my apps side:
postDataArray = new JSONArray(Arrays.asList(finalData));
postDataParams.put("sOrder", postDataArray);
postDataParams.put("sLocation",orderLocation);
postDataParams.put("sheetName",sheetName);
Log.e("params",postDataParams.toString());
finalData is a String[] that consists of 2 entries. "Location" "Data"
if i send finalData[0] as a control then it picks up the first entry, but it gives me this error instead:
[Ljava.lang.Object;@5c0b25d1
The google script needs to take either an array straight or convert a string into an array, and I am stuck on this conversion.
so google script must take the array
finalData = {"Location","Data"}
and convert it into:
[Location]
[Data]