Currently, we have the following properties in templates.json:
While literal strings – which are escaped in modelica-json – are stored unescaped "\"String literal\"" → "String literal".
The logic is backwards.
-
In the first case we should simply store "value": true since we have a bare Boolean, so really no need for the expression wrapper with "operator": "none".
-
In the second case, there is now way on the client side to distinguish between literal strings and instance names. If anywhere, the expression wrapper with "operator": "none" should be used here, for the client to resolve. (*)
(*) Another option would be to store literal strings with escape characters in templates.json. However, the standard practice in data interchange (JSON, HTML forms, REST APIs) is to store strings as plain strings (unescaped). To stick to that practice, the distinction between plain strings and instance names should rather be structural in templates.json.
Side Issue – Invalid String Comparison
With string-type variables such as parameter String str = "AAA", the client would fail evaluating the following equation str == "AAA". The function resolveToValue is called on each operand and returns null if the instance lookup fails. So the equation becomes "AAA" === null after lookup, which evaluates to false.
Enumeration-type comparison succeeds though because of isModelicaPath early return inside resolveToValue.
So the following equation is properly handled by the client.
Currently, we have the following properties in
templates.json:While literal strings – which are escaped in modelica-json – are stored unescaped
"\"String literal\"" → "String literal".The logic is backwards.
In the first case we should simply store
"value": truesince we have a bare Boolean, so really no need for the expression wrapper with"operator": "none".In the second case, there is now way on the client side to distinguish between literal strings and instance names. If anywhere, the expression wrapper with
"operator": "none"should be used here, for the client to resolve. (*)(*) Another option would be to store literal strings with escape characters in
templates.json. However, the standard practice in data interchange (JSON, HTML forms, REST APIs) is to store strings as plain strings (unescaped). To stick to that practice, the distinction between plain strings and instance names should rather be structural intemplates.json.Side Issue – Invalid String Comparison
With string-type variables such as
parameter String str = "AAA", the client would fail evaluating the following equationstr == "AAA". The functionresolveToValueis called on each operand and returns null if the instance lookup fails. So the equation becomes"AAA" === nullafter lookup, which evaluates to false.Enumeration-type comparison succeeds though because of
isModelicaPathearly return insideresolveToValue.So the following equation is properly handled by the client.
{ "operator": "==", "operands": [ "secOutRel.typSecRel", // resolveToValue returns the actual variable value "Buildings.Templates.AirHandlersFans.Types.ReliefReturnSection.ReturnFan" // resolveToValue returns it as-is because `isModelicaPath` returns true ] },