Check for the length of the JSON array before using

I've had panics after receiving an empty array from a subscription
Merge pull request #4 from jobi/check-length

Check for the length of the JSON array before using