Skip to content

Commit

Permalink
Merge pull request #300 from test-fullautomation/namsonx/task/stabi_b…
Browse files Browse the repository at this point in the history
…ranch

Namsonx/task/stabi branch
  • Loading branch information
test-fullautomation authored May 14, 2024
2 parents 2e8e25a + 236ab6d commit d3213e9
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 17 deletions.
Binary file modified JsonPreprocessor/JsonPreprocessor.pdf
Binary file not shown.
4 changes: 2 additions & 2 deletions JsonPreprocessor/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
#
# Version and date of JsonPreprocessor
#
VERSION = "0.5.0"
VERSION_DATE = "10.04.2024"
VERSION = "0.6.0"
VERSION_DATE = "14.05.2024"

20 changes: 10 additions & 10 deletions config/robotframework_aio/release_items_JsonPreprocessor.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,26 +107,26 @@
,
"0.12." : [
"
* JsonPreprocessor returns a dotdict.
* Changed data type of return value

JsonPreprocessor now supports returning a DotDict after loading jsonp files. It facilitates seamless
navigation through dictionary structures, making it easier to access values.
**JsonPreprocessor** now returns a ``dotdict`` (instead of a standard Python dictionary). With the ``dotdict`` notation, dictionary keys can be accessed as attributes.
The resulting code is shorter and therefore easier to read.

* Blocked dynamic key names.
* Blocked dynamic key names

Previously, JsonPreprocess allows dynamic key names as example below:
In opposite to previous versions of the **JsonPreprocessor**, the creation of new keys based on parameter (dynamic key names), **is not supported an more**!

Example:

| ``\u007b``
| ``\"param1\" : \"ABC\",``
| ``\"param2\" : \"XYZ\",``
| ``\"$\u007bparam2\u007b\" : 1``
| ``\"$\u007bparam2\u007d\" : 1``
| ``\u007d``

And parameter ``\"XYZ\"`` is created with value ``1``.
This code previously created a new parameter ``\"XYZ\"`` with value ``1``. Now an error message will be raised.

Now, the parameter ``\"XYZ\"`` will no longer be created; instead, an error message will be raised.

* Improved error messages.
* Improved error messages
"
]
}
Expand Down
78 changes: 73 additions & 5 deletions packagedoc/additional_docs/The JSONP format.tex
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ \section{Import of JSON files}

% --------------------------------------------------------------------------------------------------------------

\section{Overwrite parameters}
\section{Overwrite parameters}\label{overwrite-parameters}

We take over the scenario from the previous section: We still have a JSON file \plog{componentA.jsonp} containig the parameters for
component \textit{A}, a JSON file \plog{componentB.jsonp} for component \textit{B} and a JSON file \plog{common.jsonp} for both components.
Expand Down Expand Up @@ -986,10 +986,78 @@ \section{\texttt{dotdict} notation}\label{dotdict-notation}
% --------------------------------------------------------------------------------------------------------------
% \newpage
% \section{Substitution of dollar operator expressions}
% TODO: Currently nothing imortant to be explained here any more because of features of the JsonPreprocessor have been reduced.
% "Dynamic key names" still under discussion: https://github.com/test-fullautomation/python-jsonpreprocessor/issues/270
\newpage
\section{Dynamic key names}
In section \hyperref[overwrite-parameters]{Overwrite parameters} we mentioned the possibility to define the value of string parameters dynamically, e.g. in this way:
\begin{pythoncode}
"str_val" : "ABC",
"newparam1" : "prefix_${str_val}_suffix",
\end{pythoncode}
The value of \pcode{newparam1} is defined by an expression that is encapsulated in quotes and contains - beneath hard coded parts - a dollar operator expression
that is the dynamic part.
The same is also possible on the left hand side of the colon. In this case the name of a parameter is created dynamically.
\vspace{2ex}
\textbf{Example:}
\begin{pythoncode}
"strval" : "A",
"dictval" : {"A_2" : 1},
${dictval}['${strval}_2'] : 2
\end{pythoncode}
In second line a new dictionary with key \pcode{A_2} is defined. In third line we overwrite the initial value of this key with another value.
The name of this key is defined with the help of parameter \pcode{strval}.
\vspace{2ex}
\textbf{Outcome:}
\begin{pythonlog}
{'dictval': {'A_2': 2}, 'strval': 'A'}
\end{pythonlog}
\vspace{2ex}
The same in dotdict notation:
\vspace{2ex}
\begin{pythoncode}
"strval" : "A",
"dictval" : {"A_2" : 1},
${dictval.${strval}_2} : 3
\end{pythoncode}
\textbf{The precondition for using dynamic key names is that a key with the resulting name (here \pcode{A_2}) does exist already.
Therefore this mechanism can be used to overwrite the value of existing keys, but cannot be used to create new keys!}
\vspace{2ex}
This will not work:
\vspace{2ex}
\begin{pythoncode}
"strval" : "A",
"dictval" : {"${strval}_2" : 1}
\end{pythoncode}
\vspace{2ex}
\textbf{Outcome:}
\begin{pythonlog}
<TODO: error message>
\end{pythonlog}
% --------------------------------------------------------------------------------------------------------------
Expand Down

0 comments on commit d3213e9

Please sign in to comment.