Sometimes you have to map a LOT of columns from one table to another and create a really big JSON template.
I had to do a table with over 100 columns, so I built a template generator to provide a dropdown menu of columns and add all the extra characters.
Just paste in your two rows of column headers, and use the dropdown to finish generating your template.
The sheet is public, but view-only. Copy the template to your GDrive to use.
15 Likes
This is very handy. I usually do these in Notepad++ but will switch to this method. Thanks @GreenFlux
1 Like
@Bellave_Jayaram
I have created a copy of this sheet under gDrive > able3ventures. FYI.
2 Likes
@GreenFlux
In your gSheet, there is a TEMPLATE sheet. Provided you place below sheet formula in [C1] cell, it will eliminate the last comma (,) in the generated payload and also eliminate the empty payload generation in blank cells:
={"Template Row";ARRAYFORMULA(IF(LEN(A2:A),IF(LEN(A3:A),""""&A2:A&""""&": "&""""&"<<["&B2:B&"]>>"&""""&",",""""&A2:A&""""&": "&""""&"<<["&B2:B&"]>>"&""""),""))}
3 Likes
@GreenFlux
It can even be re-arranged like this:
Sheet expression in [C1]
={"Template Row";ARRAYFORMULA(IF(LEN(A2:A),""""&A2:A&""""&": "&""""&"<<["&B2:B&"]>>"&"""",""))}
Sheet expression in [D1]
="{"&CHAR(10)&JOIN(","&CHAR(10),INDIRECT("C2:"&ADDRESS(ARRAYFORMULA(IFNA(MATCH(2,1/(C:C<>"")))),3,4,TRUE)))&CHAR(10)&"}"
which will produce a concatenated payload with the correct syntax
6 Likes
Nice touch! Thanks, @LeventK I updated the public version.
2 Likes
Hereβs a related tip for generating a list of all columns in your app. It works well with the template in this post because you need a list to feed the dropdowns anyway.
[Auto-Fill a Sheet with All Table/Column Names from Your App](https://community.appsheet.com/t/auto-fill-a-sheet-with-all-table-column-names-from-your-app/29169) Tips & Tricks ?
Have you ever wanted a list of all Tables and Column Names in your app, displayed IN your app (not just in the editor)? [Screen Shot 2020-08-11 at 7.46.38 AM] This can be useful for feeding dropdowns in other tables, especially when using another table to control security, user-permissions, etc. This method uses Google Apps Script to write a custom function that can be used as a sheet formula. [2020-08-11 07.31.28] Just open the script editor, and paste in the following code: [Screen Shot 20β¦
1 Like
I also created a quick way to generate a JSON string for physical columns
[Creating JSON data string using Google Sheet formula](https://community.appsheet.com/t/creating-json-data-string-using-google-sheet-formula/47634) Tips & Tricks ?
If you want to create an adaptive JSON data string for a table, use the following formula =β{β & char(34) & JOIN(char(34) & β,β & char(34), JOIN(char(34) & β:β & char(34), {$A$1, INDIRECT(βAβ & ROW())}), JOIN(char(34) & β:β & char(34), {$B$1, INDIRECT(βBβ & ROW())}) ) & char(34) & β}β & β}β You can add more columns as you needed. Usually put the JSON column at the end of a table. It is a less buggy way to generate JSON strings for physical columns since it does not rely on the column naβ¦
Might be helpful for few use cases
1 Like