cancel
Showing results for 
Search instead for 
Did you mean: 

{key: value} type with dynamic key name

vobu
Active Contributor

Hi,

is it possible to model a generic key: value Object-like type in a .cds with a dynamic key name?
à la TypeScript Record<String, String>

So e.g. a modeled action

action bla(id: String, variables: array of Record<String,String>);

could be called with the payload

POST http://localhost:4004/bla
Content-Type: application/json

{
    "id": "4711",
    "variables": [
        {"i": "hope"},
        {"this": "is"},
        {"possible": "isit?"}
    ]
}
View Entire Topic
0 Kudos

No, this is not possible.

The best you can do currently is to model "variables" as String or "array of String", with the (implicit) extra knowledge that the content of this String is a JSON of a certain form.