FEEL 语法:如何引用字符串文字语法规则指定的上下文条目?
FEEL Grammar: How to refer to context entries specified by a string literal grammar rule?
A context entry
& key
由以下语法定义(cf DMN v1.2, page 111, Section 10.3.1.2)
60. context entry = key , ":", expression;
61. key = name | string literal;
考虑上下文对象的以下实例
{ "12" : "hello" }
如何从这样的对象访问 "hello"
?
这可能是语法问题吗?不确定这种加入是否有效。
根据DMN specification,由于“12”无法转换为合法名称,我同意你的看法,无法使用点运算符访问。
但是您可以使用内置函数 get value()
至于规格:
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").
例如:
get value({ "12" : "hello" }, "12")
这是有效的 FEEL,将导致 "hello"
。
我发现语法没有问题。
我相信访问此条目值的唯一方法是使用内置函数。
A context entry
& key
由以下语法定义(cf DMN v1.2, page 111, Section 10.3.1.2)
60. context entry = key , ":", expression;
61. key = name | string literal;
考虑上下文对象的以下实例
{ "12" : "hello" }
如何从这样的对象访问 "hello"
?
这可能是语法问题吗?不确定这种加入是否有效。
根据DMN specification,由于“12”无法转换为合法名称,我同意你的看法,无法使用点运算符访问。
但是您可以使用内置函数 get value()
至于规格:
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").
例如:
get value({ "12" : "hello" }, "12")
这是有效的 FEEL,将导致 "hello"
。
我发现语法没有问题。 我相信访问此条目值的唯一方法是使用内置函数。