我正在尝试解析返回 CSV 数据(没有标题)的旧 API 的结果。该parse-response
功能很好用,但是当我尝试检查它时,verify-response
它会以ArityException Wrong number of args (0) passed to: PersistentHashMap
. 如何通过检查键字段并在无效时创建替代错误哈希映射的函数传递哈希映射?
(def response-fields
[:response_code :response_text
:address :city :state :zip_code :country
:phone :fax :email
:first_name :last_name :company
:special_instructions :SpecialCode
])
(defn parse-response
"One line CSV file"
[response]
(zipmap response-fields
(first (csv/read-csv (:body response)))))
(defn verify-response
"Get response if code is valid"
[response-map]
(cond (some? (:response_code response-map)) (response-map)
:else
{:response_code "911"
:response_text "API Failure"}))