use json_encode where possible