我正在使用HTTParty发送POST请求.所需的变量之一是数组.这是我用来发送的代码:
response = HTTParty.post url, :body =>
{"key"=>'XYZ123',
"content"=>
[{"placename"=>"placeholder",
"placecontent"=>"sample content"}],
etc. }
Run Code Online (Sandbox Code Playgroud)
API需要看到:
"content": [
{
"placename": "placeholder",
"placecontent": "sample content"
}
],
Run Code Online (Sandbox Code Playgroud)
但是,当我检查API上的请求收到日志时,我看到我的代码正在生成:
"content": [
{
"placename": "placeholder"
},
{
"placecontent": "sample content"
}
],
Run Code Online (Sandbox Code Playgroud)
如何阻止数组记录分成两部分?
谢谢.
编辑:所需的代码输出相当于:
...&content[0][placename]=placeholder&content[0][placecontent]=sample%20content...
Run Code Online (Sandbox Code Playgroud)