fn list_to_json(list: &RList) -> Result<Value, RError>
Convert an R list to JSON. Named lists become objects; unnamed lists become arrays.