added extra check if json is invalid

done for [AGIOS-315](https://issues.jboss.org/browse/AGIOS-315)

@corinnekrych mind to have a look?