How to create array of objects using DTDL?

Harish 26 Reputation points
2020-10-28T07:49:07.75+00:00

I have DTDL model similar to below.

How I can store lat,long array of locations using objects. Is there a support in DTDL to accept array of objects? Or what is the alternate way to provide array of objects.

{
"@id": "dtmi:DigitalTwins:BasicInfra;2",
"@type ": "Interface",
"displayName": "BasicInfra interface model",
"@Георгий Георгиевский ": "dtmi:dtdl:context;2",
"contents": [
{
"@type ": "Property",
"name": "name",
"schema": "string"
},
{
"@type ": "Property",
"name": "location",
"description": "Polygon/PolyLine Format Location",
"schema": {
"@type ": "Object",
"fields": [
{
"name": "x",
"schema": "double"
},
{
"name": "y",
"schema": "double"
}
]
}
},
{
"@type ": "Relationship",
"name": "contains"
}
]
}

Azure Digital Twins
Azure Digital Twins
An Azure platform that is used to create digital representations of real-world things, places, business processes, and people.
231 questions
{count} votes

1 answer

Sort by: Most helpful
  1. QuantumCache 20,266 Reputation points
    2020-10-28T21:25:05.21+00:00

    Hello @Harish ,
    Thanks for posting this question over this forum.

    We got a response from Microsoft's Product Team.

    At the moment, we don't support arrays in properties.

    Please follow Azure Digital Twins updates, blogs, and announcements to get the latest information on upcoming features. Also Product Updates page.

    Updated: 11/16/2020: Posting Workaround suggested by the Product Team to achieve this scenario

    There are a couple of approaches that could be taken:

    • If the maximum size of the array is small, then it might be reasonable to explicitly create the fields in an object. For example, a line made up of two points could be modeled as an object with a point1 field and point2 field, instead of an array of points.
    • If the number of elements in the array is variable, a DTDL Map (dictionary) could be used with the index value as the key name ("0", "1", etc.). This approach requires some additional client code to implement the array over the map structure.

    Please let me know if you need further help in this matter.

    Thank you,
    Satish.

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.