FEEL Grammar: How to refer to context entries specified by a string literal grammar rule?

172 views Asked by At

A context entry & key are defined by the following grammar (cf DMN v1.2, page 111, Section 10.3.1.2)

60. context entry = key , ":", expression;
61. key = name | string literal;

Consider the following instance of a context object

{ "12" : "hello" }

How do I access "hello" from such an object?

Could this be an issue in the grammar? Not sure if this kind of accession is valid.

1

There are 1 answers

0
tarilabs On BEST ANSWER

Accordingly to DMN specification, as "12" cannot be transformed into a legal name I concur with you, cannot be accessed with the dot operator.

But you can use the built-in function get value() as for the spec:

If key1 is not a legal name or for whatever reason one wishes to treat the key as a string, the following syntax is allowed: get value(m, "key1").

For example:

get value({ "12" : "hello" }, "12")

this is valid FEEL and would result in "hello".

I see no issue in the grammar. I believe the only way to access this entry value is by using the built-in function.