Skip to main content

hi, 

When creating json messages for a 3rd party API, we use SQL to create the json structure. This json message has > 100 fields, and most of these fields are in our datamodel. But, of course, our column names do differ from the API fields, so we have to alias these fields in the procedure.

Is there a way to have our column names following the TW naming convention, and register the API field labels? I see columns have alias property in the data domain, can we use this?

 

Hi Tejo, 

I suppose you are creating the JSON messages inside Control procedures. Here you have full control over how you combine information from your model. You could make use of the Column alias field, but it may be better to use Tags for this on your columns. This could even be generated automatically using Dynamic model procedure, creating Tags with the column name as default for example, and leaving the generated_by_control_proc_id empty so you can make exceptions for the columns that need it.

Hope that helps!


Example out of the Export project version task:

--Export  TAB]
insert into @data (data_tab_name, json_data)
select ''TAB]',
(select
COL] as COL_NAME]]COMMA]
from TAB] t1
for json path)

>TAB] → Table name - tab_id

>COL] → Column name - col_id

lCOMMA] → Add a comma after every row except the last one

Replace these eTEXT] using Control procedure code


Thanks Mark, I’m gonna try this!