Home » Eclipse Projects » Eclipse Titan » RDF-related encodings in Titan
| | |
Re: RDF-related encodings in Titan [message #1824447 is a reply to message #1824442] |
Wed, 15 April 2020 12:29 |
|
Hi Sascha,
indeed, the @ character is no accepted in JSON encoding variants; we will look into the possibility to relax this restriction.
As a quick and dirty hack I can propose you the following:
-when encoding, use a token different from @, but easy to detect
- post encoding , replace the token with @
-when receiving the JSON instance, replace @ with token and then decode
(see attached code)
The downside of this-besides being a hack- is that the token will become a restricted expression, i.e. cannot be used in other parts of the JSON; this is of little practical impact, if the token is carefully chosen ("atsupercalifragistic" in my example, to be replaced with "@" back and forth).
For replacement of substrings, functions from TCCConversion_Functions library can be used.
The other option mentioned by Gabor is also valid, I have attached an example as well. JSON will be decoded into a generic TTCN-3 structure that
unfortunately is quite ugly; nonetheless this requires the least initial investment as there is no need of any further TTCN-3 types.
As an example , this JSON-LD
{
"@context": {
"name": "http://xmlns.com/foaf/0.1/name",
"knows": "http://xmlns.com/foaf/0.1/knows"
},
"@id": "http://me.markus-lanthaler.com/",
"name": "Markus Lanthaler",
"knows": [
{
"name": "Dave Longley"
}
]
}
is decoded as below:
JSON_object := {
{
key := "@context",
val := {
JSON_object := {
{
key := "name",
val := {
JSON_string := "http://xmlns.com/foaf/0.1/name"
}
},
{
key := "knows",
val := {
JSON_string := "http://xmlns.com/foaf/0.1/knows"
}
}
}
}
},
{
key := "@id",
val := {
JSON_string := "http://me.markus-lanthaler.com/"
}
},
{
key := "name",
val := {
JSON_string := "Markus Lanthaler"
}
},
{
key := "knows",
val := {
JSON_array := {
{
JSON_object := {
{
key := "name",
val := {
JSON_string := "Dave Longley"
}
}
}
}
}
}
}
}
}
Best regards
Elemer
|
|
| |
Re: RDF-related encodings in Titan [message #1824451 is a reply to message #1824449] |
Wed, 15 April 2020 12:53 |
|
Hi Sascha, Gabor ,
please disregard my previous observation about the @ being restricted; it's not , and it should work as Gabor described, see new attachment. Hence no need to rename it.
I agree with Gabor, likely the structure does not tally.
BR
Elemer
|
|
| |
Goto Forum:
Current Time: Tue Oct 08 00:02:47 GMT 2024
Powered by FUDForum. Page generated in 0.04704 seconds
|