This morning, on a long train journey up from near Reading to Barnsley, I was hacking on a UI5 app. I had a custom module to munge some JSON data into the shape I needed, and was binding the items aggregation of a List control to part of the resulting data structure.
So I looked across to the app itself, expecting the List to be empty. But it wasn’t! It was showing exactly what I had expected to see, had the value of the property been an array. What was going on?!
After some digging, I found out. Introduced on 10 Dec 2014, within the 1.28.0 release, was a modest feature:[FEATURE] sap.ui.model.json.JSONListBinding: iterate over maps
Enhance JSONListBinding to iterate over maps (by key), not just over
arrays (by index).
I set about confirming what I’d found with a small test on Plunkr, “Aggregation Binding Test“:
But don’t take my word for it – the author has also added a test to the JSON List Binding QUnit tests:
It makes sense to blur the distinction between maps and arrays when it comes to aggregation bindings; already I have a use for it, and I didn’t even know the feature had been implemented!