Transformation JSON during Response #2565
ganeshC-Movic
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Consider Adding a Middleware Layer
In your API service, consider adding a middleware layer that transforms string fields into parsed JSON objects before sending the response to the client. Adding native support for such functionality would add great value.
Configure DAB to Parse JSON Columns
Locate Your DAB Configuration File
This is typically named something like
dabconfig.json
(or similar) where you define your entities and their mappings.Add the
jsonColumns
PropertyUnder the configuration for your stored procedure (or entity), add the names of the columns that contain JSON.
Example:
Explanation:
"YourStoredProcEntity"
is the name you use to reference this entity in your API."YourStoredProcName"
is the actual name of the stored procedure in your database."jsonColumns"
array lists the column names that contain JSON. DAB will parse these strings into JSON objects (or arrays) in the final API response.Restart or Redeploy Your API
After updating your configuration, restart or redeploy your Data API builder instance so that the changes take effect.
What to Expect
Original API Response (Before Parsing):
Transformed API Response (After Parsing):
Summary
FOR JSON PATH
or similar) comes as anNVARCHAR
string.dabconfig.json
) to add ajsonColumns
array for the columns that hold JSON. This instructs DAB to parse those string values into JSON objects/arrays in the API response.Beta Was this translation helpful? Give feedback.
All reactions