I need your help with parsing GC data table API response.
The /api/v2/flows/datatables/{datatableId}/rows/{rowId} API returns object like this:
{
"col1": "value1",
"col2": value2,
"col3": "value3",
"col4": "value4"
}.
I want to convert it to string like this:
"{"col1":"value1", col2:value2, col3:"value3", col4:"value4"}" and return as output parameter of type string.
I can receive each field separately:
{
"translationMap": {
"col1": "$.col1",
"col2": "$.col2",
"col3": "$.col3",
"col4": "$.col4"
},
"translationMapDefaults": {},
"successTemplate": "{"COL_1":$col1,"COL_2":$col2,"COL_3":$col3, "COL_4":$col4 }"
}
but can't figure out how to concatenate them to one string and return only one parameter.
Data actions are designed to return json objects. AFAIK, there's no way to have the successTemplate return a string rather than a json object.
If you tell me more about where the data action is being consumed, I may be able to help. For example in javascript, simply passing the object to the stringify function will do what you're asking for: JSON.stringify(responseObject)
I'm going to call this data action from Architect ( I can't use built-in Architect data table lookup, because my data table name is build at runtime).
The
"successTemplate": "{"Row": "$esc.jsonString(${rawResult})"}"
solved my problem.