Added end check to json parser.

This fixes a bug introduced at 1c7595e2a9d8c8b48e1864acd3d559451948380a