I already found this script by the FIWARE-Community, which converts an NGSI-v2 normalized representation into an NGSI-LD representation.
Is there something similar for the opposite direction? I am aware that most of the steps can be done backwards. However, I am not sure about the usual procedure for converting back the "type": "Property"
nodes.
E.g given an NGSI-v2 entity representation:
{
"id": "Store:001",
"type": "Store",
"name": {
"type": "Text",
"value": "Checkpoint Markt"
}
}
Running the script on this will lead to:
{
"@context": [
https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld"
],
"id": "urn:ngsi-ld:Store:Store:001",
"type": "Store",
"name": {
"type": "Property,
"value": "Checkpoint Markt"
}
}
So in this case it is quite difficult to convert the "type": "Property"
node back to "type": "Text"
.
But given the following NGSI-v2 entity representation:
{
"type": "Store",
"id": "Store:002",
"address": {
"type": "PostalAddress",
"value": {
"streetAddress": "Friedrichstra?e 44",
"addressRegion": "Berlin",
"addressLocality": "Kreuzberg",
"postalCode": "10969"
}
}
}
will be converted to:
{
"@context": [
https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld"
],
"id": "urn:ngsi-ld:Store:Store:002",
"type": "Store",
"address": {
"type": "Property",
"value": {
"streetAddress": "Friedrichstrau00dfe 44",
"addressRegion": "Berlin",
"addressLocality": "Kreuzberg",
"postalCode": "10969",
"type": "PostalAddress"
}
}
}
This is caused by a special case in the script:
if attr['type'] == 'PostalAddress':
ld_attr['value']['type'] = 'PostalAddress'
Wouldn't it be possible to extend all converted attributes with such a "type": _
-pair in their value? Or is there a reason that this is restricted in the code to the type "PostalAddress" only? Otherwise, is there any norm for converting back these "type": "Property"
nodes?
question from:
https://stackoverflow.com/questions/65831813/is-there-a-standardized-way-to-migrate-fiware-ngsi-ld-entity-representations-to