handle result/error keys in json response