Iterate through elements in array instead of object fields.
Merge pull request #2360 from refinery/issue_2338

Iterate through elements in array instead of object fields.

Fixes #2338