Refactored IN query building to use JSON API rather than array length
counting.

Refactored some loops to use the json_array_foreach macro.
Merge pull request #95 from keithj/devel

Refactoring