Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
748beab
Documentation adapted to latest changes in the JSONP format
HolQue Nov 27, 2024
74c016e
Merge pull request #396 from test-fullautomation/HolQue/task/selftest…
test-fullautomation Nov 28, 2024
477f874
Merge branch 'develop' into namsonx/task/stabi_branch
namsonx Dec 4, 2024
b9a1891
Updated inefficient regular expression based on code scanning alerts
namsonx Dec 4, 2024
f5dc78b
Ticket 347 - Update error message log.
namsonx Dec 13, 2024
3d1c159
Ticket 324 - Error message updated.
namsonx Dec 16, 2024
e2cbd6a
Ticket 349 - Improper parsing of composite data structure
namsonx Dec 20, 2024
b1142bc
Updated selftest expected results based on ticket 349
namsonx Dec 20, 2024
3d13cd7
Update F-string format while handling strings
namsonx Dec 20, 2024
5b74cd9
Ticket 352 - Raise an error message for empty key name
namsonx Dec 25, 2024
667694c
Ticket 353 - Naming convention violation (1)
namsonx Dec 25, 2024
7fc54e9
Ticket 355 - Naming convention violation (3)
namsonx Dec 25, 2024
5fe49b2
Ticket 357 - 'One character' key names
namsonx Dec 26, 2024
5b08230
Ticket 358 - Naming convention violation (4)
namsonx Dec 26, 2024
eeef4b3
Ticket 361 - Failed to recreate a list
namsonx Dec 26, 2024
c191b0a
Ticket 363 - Possible typo in error message and instance variable
namsonx Dec 26, 2024
fb309bf
Self test adapted to latest changes of the JsonPreprocessor
HolQue Jan 3, 2025
38ccaf7
Ticket 356 - Naming convention: Clarification wanted
namsonx Jan 9, 2025
e0d1c22
Updated selftest based on block blank in parameter name
namsonx Jan 9, 2025
bb4d33e
Merge pull request #404 from test-fullautomation/HolQue/task/selftest…
namsonx Jan 9, 2025
11b5082
Tiny update of key decode
namsonx Jan 9, 2025
f4bc4c9
Self test adapted to latest changes of the JsonPreprocessor
HolQue Jan 9, 2025
7317c83
Code snippet generator: Patterns extended
HolQue Jan 10, 2025
d254cd4
tiny documentation maintenance
HolQue Jan 14, 2025
054b04a
Merge pull request #409 from test-fullautomation/HolQue/task/selftest…
test-fullautomation Jan 14, 2025
fa2ca13
Merge branch 'develop' into namsonx/task/stabi_branch
namsonx Feb 6, 2025
079ad84
Updated version and history for ROBFW-AIO 0.13.2
namsonx Feb 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
399 changes: 243 additions & 156 deletions JsonPreprocessor/CJsonPreprocessor.py

Large diffs are not rendered by default.

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.8.3"
VERSION_DATE = "25.11.2024"
VERSION = "0.8.4"
VERSION_DATE = "10.2.2025"

8 changes: 4 additions & 4 deletions atest/jsonpreprocessor/test_jsonpreprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,8 @@ def test_utf8_encoding_both_key_and_value(self):
sJsonfile = os.path.abspath("../testdata/config/08_utf8_encoding/utf8_format_02.jsonp")
oJsonPreprocessor = CJsonPreprocessor(syntax="python")
oJsonData = oJsonPreprocessor.jsonLoad(sJsonfile)
assert oJsonData['Tiếng Đức'] == "Dies ist der UTF-8 SälfTest"
assert oJsonData['Tiếng Việt'] == "Đây là bản tự kiểm tra UTF-8"
assert oJsonData['Tiếng_Đức'] == "Dies ist der UTF-8 SälfTest"
assert oJsonData['Tiếng_Việt'] == "Đây là bản tự kiểm tra UTF-8"
assert oJsonData['日本'] == "これは UTF-8 セルフテストです"
assert oJsonData['हिंदी'] == "यह UTF-8 सेल्फ़टेस्ट है"
assert oJsonData['แบบไทย'] == "นี่คือการทดสอบตัวเอง UTF-8"
Expand Down Expand Up @@ -460,8 +460,8 @@ def test_utf8_encoding_imported_06(self):
sJsonfile = os.path.abspath("../testdata/config/08_utf8_encoding/utf8_format_03.jsonp")
oJsonPreprocessor = CJsonPreprocessor(syntax="python")
oJsonData = oJsonPreprocessor.jsonLoad(sJsonfile)
assert oJsonData['utf8']['Tiếng Đức'] == "This is German"
assert oJsonData['utf8']['Tiếng Việt'] == 84
assert oJsonData['utf8']['Tiếng_Đức'] == "This is German"
assert oJsonData['utf8']['Tiếng_Việt'] == 84
assert oJsonData['utf8']['日本'] == 1.987
assert oJsonData['utf8']['हिंदी'] == "นี่คือการทดสอบตัวเอง UTF-8"
assert oJsonData['utf8']['한국인'] == "1"
Expand Down
4 changes: 2 additions & 2 deletions atest/testdata/config/08_utf8_encoding/utf8_format_02.jsonp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

{
"Project": "JsonPreprocessor",
"Tiếng Đức": "Dies ist der UTF-8 SälfTest",
"Tiếng Việt": "Đây là bản tự kiểm tra UTF-8",
"Tiếng_Đức": "Dies ist der UTF-8 SälfTest",
"Tiếng_Việt": "Đây là bản tự kiểm tra UTF-8",
"日本": "これは UTF-8 セルフテストです",
"हिंदी": "यह UTF-8 सेल्फ़टेस्ट है",
"แบบไทย": "นี่คือการทดสอบตัวเอง UTF-8",
Expand Down
4 changes: 2 additions & 2 deletions atest/testdata/config/08_utf8_encoding/utf8_format_03.jsonp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
{
"Project": "JsonPreprocessor",
"utf8": {
"Tiếng Đức": "Dies ist der UTF-8 SälfTest",
"Tiếng Việt": "Đây là bản tự kiểm tra UTF-8",
"Tiếng_Đức": "Dies ist der UTF-8 SälfTest",
"Tiếng_Việt": "Đây là bản tự kiểm tra UTF-8",
"日本": "これは UTF-8 セルフテストです",
"हिंदी": "यह UTF-8 सेल्फ़टेस्ट है",
"แบบไทย": "นี่คือการทดสอบตัวเอง UTF-8",
Expand Down
4 changes: 2 additions & 2 deletions atest/testdata/config/import/utf8_format_data_03.jsonp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
// limitations under the License.

{
${utf8}['Tiếng Đức']: "This is German",
${utf8}['Tiếng Việt']: 84,
${utf8}['Tiếng_Đức']: "This is German",
${utf8}['Tiếng_Việt']: 84,
${utf8}['日本']: 1.987,
${utf8}['हिंदी']: "${utf8}['แบบไทย']",
${utf8}['한국인']: "${version}['patchversion']"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
"
]
,
"0.12.1.;0.13.0.;0.13.1." : [
"0.12.1.;0.13.0.;0.13.1.;0.13.2." : [
"
* Changed data type of return value

Expand Down
3 changes: 3 additions & 0 deletions packagedoc/additional_docs/History.tex
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,7 @@
\historyversiondate{0.8.3}{11/2024}
\historychange{- Fixed bugs and updated error messages related to dynamic imports}

\historyversiondate{0.8.4}{02/2025}
\historychange{- Fixed bugs, updated error messages, and improved composite data structure handling}

\end{packagehistory}
149 changes: 143 additions & 6 deletions packagedoc/additional_docs/The JSONP format.tex
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ \section{Boolean and null values}

JSON supports the boolean values \pcode{true} and \pcode{false}, and also the null value \pcode{null}.

In Python the corresponding values are different: \pcode{True}, \pcode{False} and \pcode{None}.
In Python, the corresponding values differ: \pcode{True}, \pcode{False} and \pcode{None}.

Because the \pkg\ is a Python application and therefore the returned content is required to be formatted Python compatible,
the \pkg\ does a conversion automatically.
Expand Down Expand Up @@ -151,6 +151,20 @@ \section{Comments}
{'testlist': ['A1', 'D4']}
\end{pythonlog}

\vspace{2ex}

\section{Naming convention}

All key names in JSONP files must adhere to the following rules:

\begin{itemize}
\item Key names can only consist of letters, digits and the following special characters: \pcode{_ + - * / \\\\ @}
(\textit{backslashes are allowed but have to be masked}).
\item Key names have to start with a letter, a digit or an underscore.
\item Key names must not be empty strings. But leading and trailing blanks will be removed (and therefore do not cause errors).
Also blanks in between allowed characters are not allowed.
\end{itemize}

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

\newpage
Expand Down Expand Up @@ -260,10 +274,102 @@ \section{Import of JSON files}

It can be seen that the returned dictionary contains both the parameters from the loaded JSON file and the parameters imported by the loaded JSON file.

\vspace{2ex}

\textbf{Multiple imports of the same file}

A JSONP file can be imported more than once anywhere in the set of JSONP configuration files. This mechanism can be used to define a common part for different subkeys.

\vspace{2ex}

\textbf{Example:}

\vspace{2ex}

\textbullet \plog{common.jsonp}

\begin{pythoncode}
{
// common parameters
"common_param_1" : "common value 1",
"common_param_2" : "common value 2"
}
\end{pythoncode}

\textbullet \plog{componentA.jsonp}

\begin{pythoncode}[linebackgroundcolor=\hlcode{6,12}]
{
// component A parameters
"componentA_param_1" : {
"componentA_param_1_a" : "componentA_param_1_a value",
// common parameters within componentA_param_1
"[import]" : "./common_config/common.jsonp",
"componentA_param_1_b" : "componentA_param_1_b value"
},
"componentA_param_2" : {
"componentA_param_2_a" : "componentA_param_2_a value",
// common parameters within componentA_param_2
"[import]" : "./common_config/common.jsonp",
"componentA_param_2_b" : "componentA_param_2_b value"
}
}
\end{pythoncode}

\vspace{2ex}

\textbf{Outcome:}

% \vspace{2ex}

The content of \plog{common.jsonp} is part of \pcode{componentA_param_1} and also part of \pcode{componentA_param_2}.

\begin{pythonlog}
{'componentA_param_1': {'common_param_1': 'common value 1',
'common_param_2': 'common value 2',
'componentA_param_1_a': 'componentA_param_1_a value',
'componentA_param_1_b': 'componentA_param_1_b value'},
'componentA_param_2': {'common_param_1': 'common value 1',
'common_param_2': 'common value 2',
'componentA_param_2_a': 'componentA_param_2_a value',
'componentA_param_2_b': 'componentA_param_2_b value'}}
\end{pythonlog}

\newpage

\textbf{Dynamic import paths}

The values of \pcode{"[import]"} keys must be of type \pcode{str}. Therefore it's possible to use
dollar operator expressions inside import paths.

An alternative version of the file \plog{componentA.jsonp} from the example above, can look like this:

\begin{pythoncode}[linebackgroundcolor=\hlcode{2,7,13}]
{
"common_config_dir" : "./common_config",
// component A parameters
"componentA_param_1" : {
"componentA_param_1_a" : "componentA_param_1_a value",
// common parameters within componentA_param_1
"[import]" : "${common_config_dir}/common.jsonp",
"componentA_param_1_b" : "componentA_param_1_b value"
},
"componentA_param_2" : {
"componentA_param_2_a" : "componentA_param_2_a value",
// common parameters within componentA_param_2
"[import]" : "${common_config_dir}/common.jsonp",
"componentA_param_2_b" : "componentA_param_2_b value"
}
}
\end{pythoncode}

The outcome is the same like in the previous example.

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

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

\section{Overwriting parameters}\label{overwriting-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 @@ -530,8 +636,8 @@ \section{Overwrite parameters}\label{overwrite-parameters}

\begin{itemize}
\item Existing parameters are accessed by a dollar operator and a pair of curly brackets (\pcode{$\{...\}}) with the parameter name inside.
\item If the entire expression of the right hand side of the colon is such a dollar operator expression, it is not required any more
to encapsulate this expression in quotes.
\item If the entire expression of the right hand side of the colon is such a dollar operator expression, it is not required
to encapsulate this expression in quotes (in opposite to what pure JSON would require).
\item Without quotes, the dollar operator keeps the data type of the referenced parameter. If you use quotes, the value of the used parameter
will be converted to type \pcode{str}. This implicit string conversion is limited to parameters of simple data types like integers and floats.
Composite data types like lists and dictionaries cannot be used for that.
Expand All @@ -552,7 +658,7 @@ \section{Overwrite parameters}\label{overwrite-parameters}
"int_val_b" : ${int_val},
\end{pythoncode}

It is not required any more to encapsulate dollar operator expressions at the right hand side of the colon in quotes.
It is not required to encapsulate dollar operator expressions at the right hand side of the colon in quotes.
But nevertheless, it is possible to use quotes. In case of:

\begin{pythoncode}
Expand Down Expand Up @@ -992,13 +1098,44 @@ \section{\texttt{dotdict} notation}\label{dotdict-notation}
'dict_2_A_key_2 value 2']}}]}
\end{pythonlog}


% commented out because of
% https://github.com/test-fullautomation/python-jsonpreprocessor/issues/349

% \vspace{2ex}

% \textbf{Parameter scope}

% The following JSONP example defines a parameter with name \pcode{"param"} two times.
% In case of the innermost \pcode{"param"} shall be overwritten, the full scope of this
% parameter must be used.

% \begin{pythoncode}
% {
% "param" : 1,
% "params" : {"001" : {
% "param" : 2
% }
% },
% ${params.001.param} : 3
% }
% \end{pythoncode}

% \vspace{2ex}

% \textbf{Outcome:}

% \begin{pythonlog}
% DotDict({'params': DotDict({'001': DotDict({'param': 3})}), 'param': 1})
% \end{pythonlog}

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

\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:
In section \hyperref[overwriting-parameters]{Overwriting parameters} we mentioned the possibility to define the value of string parameters dynamically, e.g. in this way:

\begin{pythoncode}
"str_val" : "ABC",
Expand Down
3 changes: 3 additions & 0 deletions test/JPP_TestUsecases.csv
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@ JPP_2000|PARAMETER_SCOPE|GOODCASE|JSON file with nested dictionary, in which a p
JPP_2001|PARAMETER_SCOPE|GOODCASE|JSON file with nested dictionary, in which a parameter is overwritten (2)
JPP_2002|PARAMETER_SCOPE|GOODCASE|JSON file with nested dictionary, in which a parameter is overwritten (3)
JPP_2003|PARAMETER_SCOPE|GOODCASE|JSON file with nested dictionary, in which a parameter is overwritten (4)
JPP_2004|PARAMETER_SCOPE|GOODCASE|JSON file with nested dictionary, in which a parameter is overwritten (5)
JPP_2005|PARAMETER_SCOPE|GOODCASE|JSON file with nested dictionary, in which a parameter is overwritten (6)
JPP_2006|PARAMETER_SCOPE|GOODCASE|JSON file with nested dictionary, in which a parameter is overwritten (7)
JPP_2007|PARAMETER_SCOPE|GOODCASE|JSON file with nested dictionary, in which a parameter is overwritten (8)
JPP_2050|PARAMETER_SCOPE|BADCASE|JSON file containing a parameter with missing scope (1)
JPP_2051|PARAMETER_SCOPE|BADCASE|JSON file containing a parameter with missing scope (2)
Expand Down
Loading
Loading