我需要在R中复制以下Python代码:

payloadObject = {
        'request':'/v1/balances',
        'nonce':str(1417217972400792),
        'options':{}
}
payload_json = json.dumps(payloadObject)
payload = base64.b64encode(bytes(payload_json, "utf-8"))


到目前为止,我有

require("RJSONIO")

payloadObject <- list(request = "/v1/balances", nonce = "1417217972400792", options = {})
payload_json <- toJSON(payloadObject)


您能帮忙处理最后一行有效负载= base64.b64encode(bytes(payload_json,“ utf-8”))吗?

最佳答案

RCurl具有base64,可用于最后一部分。我还使用了jsonlite vs RJSONIO(后者是更现代的fork):

library(RCurl)
library(jsonlite)

payloadObject <- list(request = "/v1/balances",
                      nonce = "1417217972400792",
                      options = {})
payload_json <- toJSON(payloadObject)
payload <- base64(payload_json)

10-06 05:39