better json error catching