|
Re: How to convert JSON into TTCN-3 [message #1805840 is a reply to message #1805793] |
Thu, 25 April 2019 09:15 |
|
Hi Yann,
currently there is no support in Titan to automate JSON to TTCN-3 conversion;
there is for the opposite direction though , which is probably more complex.
A conversion can be done manually, as described in the (simplistic) example
Using JSON in TTCN-3 and Titan Part I: Testing REST / JSON web services
https://www.eclipse.org/forums/index.php/t/1068704/
The recommended workflow is:
-The JSON document has to be found a JSON schema that covers it
-a TTCN3 type equivalent to this schema has to be found
-this type than can be used for variables that can be JSON encoded
Now probably this sounds more complicated than it really is .
JSON has only seven basic types:
-JSON Strings can be converted to TTCN-3 charstring or universal charstring
-JSON Numbers to TTCN-3 integers or float
-JSON Objects to TTCN-3 records or sets
-JSON Arrays to TTCN-3 arrays
-JSON boolean to TTCN-3 boolean
-JSON Null to the ASN.1 Null that can be imported into TTCN-3
JSON-Generic-Null-Def
DEFINITIONS ::= BEGIN
IMPORTS;
JSON-null-type ::= NULL
END
The principles of TTCN-3 to JSON conversion are described in
the refguide
4.26.4. Converting TTCN-3 and ASN.1 types to a JSON schema
their inverse can be easily applied.
So one has to assemble the TTCN-3 equivalent, including the encoding variants, of the JSON documents to be converted. Once you have done one or two examples it should come naturally.
Of course the alternative is to write a script that does this automatically
but so far we did not find this justifiable.
Best regards
Elemer
|
|
|
|
Powered by
FUDForum. Page generated in 0.02945 seconds