Ruby Rest Client 发送 Escaped JSON

Ruby Rest Client sending Escaped JSON

我正在使用 Sinatra 和 rest-client 发送 JSON 有效负载并对其进行处理(请求需要密钥对签名)。

但是看起来 rest-client 正在发送转义 JSON 通过。

我的 RestClient 日志:

RestClient.post uriHere, "{\"eventID\":1}", "Accept"=>"application/json", "Accept-Encoding"=>"gzip, deflate", "Authorization"=>"Bearer tokenHere", "Content-Hash"=>"sha1 signatureHere", "Content-Length"=>"xyz", "Content-Type"=>"application/json", "Date"=>"Thu, 29 Jan 2015 22:26:47 GMT"

我无法真正验证端点是否正在读取转义字符,但如果它像那样发送它们,显然它是无效的 JSON。我试过 .gsub 但它没有删除多余的斜杠。

想法?

我几乎可以肯定它就像日志中那样,即实际有效载荷是有效的 JSON。

表示是文本,应该通过JSON.parse:

new_hash = JSON.parse(the_payload)

那么new_hash['eventID']就是1