Skip to Main Content

ORDS, SODA & JSON in the Database

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Key Case Formatting in ORDS JSON Responses

DBManMay 15 2024

I would like to propose an enhancement to ORDS to provide more flexibility in controlling the case of keys in the generated JSON responses. Currently, when generating JSON responses from SQL queries, ORDS automatically converts column aliases to lowercase keys in the JSON output.

However, this automatic conversion poses challenges when users require keys to be in a different case, such as camel case.

While the workaround of generating JSON manually in the handler block is possible, it adds immense complexity to the code. This approach leads to bloated code, significantly longer implementation times, and diminished readability. Ultimately, it undermines the efficiency of using ORDS.

There have been several questions from the community regarding this issue, indicating a widespread need for better support.

Some possible approaches to support JSON keys casing:

  1. Configuration Parameter: Introduce a configuration parameter in ORDS that allows users to specify desired case format for keys. This parameter could provide options for lowercase (existing behavior), uppercase, or maintaining the case as defined in the SQL query.
  2. Endpoint Handler Parameter: Add a parameter on the details page of the endpoint handler that allows users to specify the desired case format for keys in the JSON response. This would provide a more granular control over the key case formatting at the endpoint level.
  3. Handler Block Utility Functions: Provide utility functions or helpers in the handler block to simplify the process of mapping column names to JSON keys in the desired case. This would allow users to generate JSON responses programmatically while maintaining flexibility.
  4. Dynamic Response Formatting: Implement dynamic response formatting options in ORDS that allow users to specify formatting rules for the JSON response, including the case of keys. This would give users greater control over the formatting of JSON responses without the need for manual intervention.

This is just outline of approaches but from the user perspective combination of options 1 and 2 would be simplest to work with and easiest to maintain. Option 1 to configure on system level. Option 2 to cover exceptional cases.

Thanks for consideration and support.

Comments
Post Details
Added on May 15 2024
5 comments
397 views