improved json handling of reply from mongodb