Irina | 2022-01-26 08:36:23 UTC | #1
Hello Experts,
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": "{\"COL1\":$col1,\"COL2\":$col2,\"COL3\":$col3, \"COL4\":$col4 }" } but can't figure out how to concatenate them to one string and return only one parameter.
Thanks, Irina
jacobshaw | 2022-01-26 22:22:15 UTC | #2
Hi Irina,
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)
Irina | 2022-01-27 18:31:47 UTC | #3
Thanks for your answer, jacobshaw.
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.
system | 2022-02-27 18:32:04 UTC | #4
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
This post was migrated from the old Developer Forum.
ref: 13330