How to get Header Labels in tablegrid from json

Hello,

When we write a Lookup() function in custom formula of a tablegrid , it extracts the coloumn headers and makes them as header lables.

If we pass a Json to the table grid, it doesnt do so. How can we ensure the json when represented on a table through a tablegrid, gets all the header labels.

I need this because.
I have a custom function, applied over a lookup. this function changes the output header structure.
So, if i directly apply the Function(lookup()) in a table grid, i get the correct output, but the lable headers are mismatch.

If I apply Function(lookup()) in a json datastore, and table grid points to this jsondatastore, I get the correct output, with correct headers, but, when i turn this table grid in selection mode, I am not able to extract data .

If the same table grid has correct labels , I am able to make selection work.

Since the header labels are dynamic, i cannot hardcode them.

any solution?