test-fullautomation / python-jsonpreprocessor

A preprocessor for json files
Apache License 2.0
2 stars 2 forks source link

Problems while accessing dictionary keys #211

Closed HolQue closed 2 months ago

HolQue commented 4 months ago

The following code creates some parameters with subkey name values and a test dictionary:

// some parameters with subkey name values
"param1" : "subKey1",
"param2" : "subKey2",
"param3" : "subKey3",
"param4" : "subKey4",

// implicitly created dictionary
${testdict1.subKey1.subKey2.subKey3.subKey4} : 1,

Now subKey4 shall be overwritten. We use a kind of mixed syntax for that:

// several ways to access subKey4 at left hand side of the colon
${testdict1}[${param1}]['${param2}']['subKey3'][${param4}] : 2,
${testdict1.${param1}.subKey2.${param3}.subKey4} : 3,

Both lines work!

Now the same on the right hand side of the colon; access to subKey4:

This works:

"param5" : ${testdict1}[${param1}]['${param2}']['subKey3'][${param4}]

param5 has integer value 3.

This does not work:

"param6" : ${testdict1.${param1}.subKey2.${param3}.subKey4}

Result:

Error: 'Invalid nested parameter format: ${testdict1.${param1}.subKey2.${param3}.subKey4} - The double quotes are missing!!!'!

This I do not understand. Why is this format invalid? My expectation would be that param6 has integer value 3.

Like proposed in error message, I added the quotes:

"param7" : "${testdict1.${param1}.subKey2.${param3}.subKey4}"

Result:

param7 has value 3. But it's an integer!

But because of the quotes around the expression, I would expect a string "3".

namsonx commented 4 months ago

Hello Holger,

I fixed this issue and pushed the change to stabi branch.

Thank you, Son

HolQue commented 3 months ago

Hi Son,

the behavior changed.

Code:

"param6" : ${testdict1.${param1}.subKey2.${param3}.subKey4}

Previously:

Error: 'Invalid nested parameter format: ${testdict1.${param1}.subKey2.${param3}.subKey4} - The double quotes are missing!!!'!

Now:

Expecting value: line 10 column 12 (char 348)'!

But expected is value 3 for param6.

Solved: param7 has string value '3' now

namsonx commented 2 months ago

Hello Holger,

All cases mentioned in this ticket are solved.

Thank you, Son

HolQue commented 2 months ago

Retest successful. Issue can be closed.

test-fullautomation commented 2 months ago

integrated in RobotFramework AIO 0.11.0