Make aJson parser more robust to come with malformed input

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 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.