Closed skounis closed 3 years ago
None otther than that is how the Sematic SG script generates them. Could be changed. What would be the reason to change it to array, from your perspective?
map
, reduce
, filter
and plenty of methods like these are availabe on or apply to map.
In similar situations, like the one we have, I always find my self start with:
var result = Object.keys(obj).map((key) => [Number(key), obj[key]]);
I expect these data to populate lists and select controls where arrays work a bit better.
JS-specific: not neccessarily an Array
, but one of the JS built-in iterables (String
, Array
,TypedArray
, Map
, Set
) or more generically something that implements the iterator protocol -> but I agree I would keep to the built-in iterables here rather than also define a custom implementation of the iterator protocol, which I find to be a very over-engineered solution for this case.
Other language bindings (e.g. Python) will directly give you an iterable by loading the JSON as-is (collection of objects) and you can use e.g. map
, reduce
, filter
style operations, so the issue is simply not present in at least some other languages. So this is really a language binding issue - all the same, a practical consideration which would make life easier for implementers using JS directly, so is worth looking into just for that.
If we change these generated valuesets to e.g. Array ( [] ), then it means we have a back-compatibility issue in that at least JS client code will have to be modified (at least, JS code) to work with either the collection of objects (as it is now) or the (admittedly far easier and more comfortable) built-in iterable type of e.g. Array.
Thoughts?
If we change these generated valuesets to e.g. Array ( [] ), then it means we have a back-compatibility issue
This already ansers it.
I do not see the need for further action.
Hi, is there any particular reason in our dataset we use collection of
object
s over anarray
of them?Instead of
https://github.com/ehn-dcc-development/ehn-dcc-schema/blob/main/valuesets/test-manf.json#L5