Search code examples
droolsdmnkogito

Kogito DMN Data Types Create New Data Type Dictionary/Map


I want to create a structure that is a map from string to array of objects (unknown number of keys that map to an array of other struct).

In other words, I want to create a new data type with the following structure:

{
  "key1": [
    {
      "objkey1": "xyz",
      "objkey2": "abc",
      "objkey3": "123"
    }
  ],
  "key2": [
    {
      "objkey1": "XYZ",
      "objkey2": "ABC",
      "objkey3": "!@#"
    },
    {
      "objkey1": "hello",
      "objkey2": "bye",
      "objkey3": "cya"
    },
    {
      "objkey1": "xyz",
      "objkey2": "abc",
      "objkey3": "123"
    }
  ],
  "key3": [
    {
      "objkey1": "foo",
      "objkey2": "bar",
      "objkey3": "789"
    },
    {
      "objkey1": "bingo",
      "objkey2": "bazinga",
      "objkey3": "12345"
    }
  ],
  ...
}

I see that I can create Strings and Structs, but I don't see how to create a key-value pair. Is this data structure not supported?


Solution

  • Beyond Kogito/Drools, this is more a broad question of DMN.

    In DMN/FEEL, a key-value pairs, a dictionary (a-la Python), a Map (a-la Java) is a FEEL Context.

    You could represent your input context already like this:

    just context

    as just a giant context.

    Or, you could get more precise this way:

    strutured

    which is more structured, as in expecting the input to contain key1, 2, 3 and each being a FEEL List of FEEL Context(s).