-
Notifications
You must be signed in to change notification settings - Fork 2
Description
JSON code
"key1" : "keyA",
"testdict" : {"keyA" : "A", "keyB" : "B"},
(1)
Access to elements with hard coded key name (encapsulated in single quotes) and key name as parameter (without single quotes) on the right hand side of the colon:
"tmp1" : ${testdict}['keyA'],
"tmp2" : ${testdict}[${key1}],
Outcome: tmp1 and tmp2 with value "A". OK, so far.
(2)
With single quotes around parameter:
"tmp3" : ${testdict}['${key1}']
Result:
Error: 'The variable '${testdict}['${key1}']' is not available!'!
Hmm. I can live with that. But nevertheless, my feeling is that this should not be an error. Why not a little bit more robust?
We speak about a dictionary key. This is expected to be of type string. The single quotes inside the square brackets indicate that the content shall be interpreted as string. The parameter key1, used as dictionary key, is already of type string. So what is the problem here? All things are completely fine already. The single quotes are irrelevant in this case and really should not harm the computation. And telling that the entire expression (variable) '${testdict}['${key1}']' does not exist, is in my opinion also not helpful - or not precise enough. Because this error message does not really tell, what exactly the problem is.
(3)
The same on the left hand side of the colon. Here it is completely other way round.
Without quotes => error
${testdict}[${key1}] : "C"
Error: 'Could not set variable 'testdict[keyA]' with value 'C'! Reason: name 'keyA' is not defined'!
With quotes => success
${testdict}['${key1}'] : "D"
Why are the single quotes a problem on the right hand side of the colon and required at the left hand side of the colon?
This overall is so much confusing and I really have problems to explain that in the documentation. I urgently ask to rework the syntax.
Metadata
Metadata
Assignees
Labels
Projects
Status