protecting json server against bad requests