Fix to protect against potential JArray foreach issue

- This issue is most likely to occur when an older version of Json.Net
  (<= 5.0.4) is GACed

#2669
#2691