Add assertion for json responses: check if a key exists

This will only check keys on the top level of the json object. Code by
@sebdd and modifications by @turanct.