interactive-matter/aJson — pull request #37 by elafargue (2013-02-09 17:16:43+00:00)
Title: Make parser more robust

The original parser does not cope gracefully with input that is
not proper json. Try sending "Hi there" to any of the library
examples and see the results.

This commit adds two things:
- the "getch" method in aJsonStream now times out after 500ms.
This removes the situation whereby the parser got often stuck
waiting forever on malformed input.
- A new "flush" method is added, because the parser leaves the
input buffer untouched in case it cannot understand the contents,
which means that it will get stuck forever again trying to parse
the same input if we try several times.

Let me know what you think, it works nicely in my situation, so I though
I would share.