test-fullautomation / python-jsonpreprocessor

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

Syntax clarification wanted #225

Open HolQue opened 4 months ago

HolQue commented 4 months ago

Instead of

"param1" : True,
"param2" : False,
"param3" : None

it is also possible to to this:

"param1" : ${True},
"param2" : ${False},
"param3" : ${None}

The result in both cases is:

{'param1': True, 'param2': False, 'param3': None}

But the question is: Shall the second option be allowed? Is this a confirmed syntax?

The second option is Robot Framework style. And there might be users who intuitively assume that this style is possible also in JSON configuration files.

Consequence 1:

If we allow this, the syntax switch CJsonPreprocessor(syntax="python") makes no sense any more. Because the second option also works with CJsonPreprocessor(syntax="json")

See also https://github.com/test-fullautomation/python-jsonpreprocessor/issues/224

Consequence 2:

If we allow this, it must work everywhere. But this does not work:

"param4" : {"A" : ${True}, "B" : 2}

Result:

Error: 'Invalid nested parameter format: ${True}, "B" - The double quotes are missing!!!'!

With reduced content it works again: "param4" : {"A" : ${True}}

Cross check:

"param1" : ${true}

Result:

Error: 'The variable '${true}' is not available!'!

OK, in this case it's detected that something does not exist.

Open questions:

Shall we allow this: "param1" : ${True} ?

Shall we allow this: "param1" : ${true} ?

Do we want CJsonPreprocessor(syntax="json") to suppress this: "param1" : ${True} ?