move json_encode to here