additional syntax checking to prevent possible segfault with improperly formed json documents