Azure / opendigitaltwins-dtdl

Digital Twins Definition Language
Creative Commons Attribution 4.0 International
466 stars 160 forks source link

Alternative for a Property with array schema #109

Closed sivaji1233 closed 3 years ago

sivaji1233 commented 3 years ago

Since we cannot use an array schema for a Property, is there any workaround? (I don't want to use Telemetry)

briancr-ms commented 3 years ago

There are a couple workarounds you could consider, depending on how extensive your needs are for arrays:

  1. If your data contains a fixed (small) number of elements, you could consider creating an object with named fields: "element1", "element2", etc.
  2. If your data is more variable, you could consider using a Map as an Array where the key values in the map are the array element numbers: { "0": "value0", "1": "value1" }. This isn't as efficient as an array and requires additional client code to use it as an array.

Neither of these workarounds are a full replacement for arrays, but may work for your solution.

danhellem commented 3 years ago

@sivaji1233 also note that array support is on our list to support sometime in summer of 2021