|How to convert JSON into TTCN-3 [message #1805793]
||Wed, 24 April 2019 08:18
| Yann Garcia
Registered: June 2016
I'm involve in some Multi-access Edge Computing (MEC) projects and there are a lot of JSON files I would like to convert in to TTCN-3 types modules.
I read all the threads regarding TITAN and JSON, but I didn't find such tool or compiler options to achieve my goals.
Please can you provide me some hint to do this JSON to TTCN-3 conversion?
Many thanks in advance for your help,
|Re: How to convert JSON into TTCN-3 [message #1805840 is a reply to message #1805793]
||Thu, 25 April 2019 09:15
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
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
DEFINITIONS ::= BEGIN
JSON-null-type ::= NULL
The principles of TTCN-3 to JSON conversion are described in
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.
Powered by FUDForum
. Page generated in 0.01694 seconds