question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Syncing Array Fields Values to Google Sheets showing [Ljava.lang.Object;@......]

See original GitHub issue

Minimal Code to Reproduce the Problem

  const allDocuments = allDocumentsWithMetadata.map(function(documentWithMetadata) {
    const document = documentWithMetadata.obj
    return document;
  });
 
  const firstDocument = allDocuments[0];  
  const columns = Object.keys(firstDocument).sort();
  Logger.log(columns);
  Logger.log(firstDocument);
  const sheet = SpreadsheetApp.getActiveSheet();
  sheet.appendRow(columns);
  
  allDocuments.forEach(function(document) {
    const row = columns.map(function(column) {
      return document[column];
    });
    sheet.appendRow(row);
  });

Explain the Problem in Detail

Firestore Documents have array fields like this image

But in Google Sheets, getting results like this image

Other Comments

Library Version: 33

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
LaughDonorcommented, Jul 13, 2020

Here’s your hint

Surprise inside!
function(column) {
    const value = document[column];
    if (Array.isArray(value)) {
        return value.join("|");
    } else {
        return value;
    }
});

Please use StackOverflow for other questions as these issues are not related to this library.

0reactions
Subroidcommented, Jul 13, 2020

Yes. That’s what I’m also trying to figure out. Can you guide me?

I don’t know what to guide you to.

  1. Your issue is unrelated to this library.
  2. You haven’t provided the results you’re trying to expect.

I want product name array values to be appeared into one cell and separated by pipe

Read more comments on GitHub >

github_iconTop Results From Across the Web

What does "[Ljava.lang.Object;@" mean?
lang..... represents object notation in Java to indicate any object such as Array,JSON in GAS.To get actual value try toString() (or) JSON.
Read more >
Using arrays in Google Sheets - Google Docs Editors Help
An array is a table (consisting of rows and columns) of values. If you want to group the values of your cells together...
Read more >
Synchronization of ArrayList in Java
There are two ways to create a Synchronized ArrayList. 1. Collections.synchronizedList() method. 2. Using CopyOnWriteArrayList. Method 1: Using ...
Read more >
Collections (Java Platform SE 7 )
Returns an array list containing the elements returned by the specified enumeration in the order they are returned by the enumeration.
Read more >
ArrayTable (Guava: Google Core Libraries for Java 19.0 API)
Fixed-size Table implementation backed by a two-dimensional array. The allowed row and column keys must be supplied when the table is created.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found