Arrays through API

Is it possible to not include the type in arrays through the API? We are using Go to get data through the API and when the array returns [“L”, 500, 600] we have a super hard time processing because of mixed types. Can we just return the array without that “L”?

Generally, Grist represents non-primitive types as [TYPE_CODE_LETTER, arguments...], and values like ["L", 500, 600] are returned for lists, including Reference List columns.

I can see the possible difficulty with the types, but I don’t know if it makes sense to add an API option for which format such things are returned in (changing the default would mess with people already using the current API).

Here are some alternatives using Grist column types and formulas:

  1. If you add a formula column of type Any and return a Reference List value (e.g. just $RefListColumn or Table1.lookupRecords(...)), then it shows up in the API as

    ["r","Table1",[500, 600]]
    

    So looking up the third element of the returned array will be the array of numbers you want.

  2. You can stringify the list into JSON in a formula, e.g.

    import json
    json.dumps($RefListColumn.id)
    

    Then the API will return a valid JSON string like "[500, 600]", which you’d need to decode as JSON to get the array.

I’ll look into those other options, thanks!