lib: handle JSON parse errors

Don't throw an uncatchable exception when the input is malformed JSON.
Forward the exception as an 'error' event that the user can handle or
ignore as s/he sees fit.

Suggested reviewers: @themitchy @Qard.  Without this patch it's dead simple to bring down the nodefly-collector (accidentally or otherwise.)