с использованием рельсов 2.3.8.
Я получаю это:
[
[0] "0",
[1] {
"name" => "Section",
"contents" => {
"0" => {
"name" => "RENAMED!",
"id" => "1"
}
}
}
]
обратите внимание на [0] и [1]
, но в моем постеЯ отформатировал JSON следующим образом:
[ {
"name":"Section",
"contents":[
{
"id":1,
"name":"RENAMED!"
}
]
}, .. more of this type of structure [
Итак, почему рельсы добавляют дополнительный массив?
Вот как я размещаю объект:
$j.ajax({
type: "POST",
url: 'http://url/objects/create/',
dataType: 'text',
async: false,
data: data_obj,
success: function () {
alert("sent");
}
});
ОБНОВЛЕНИЕ
data_obj = {
"my_object":{
"name":"hello there, I am JSON!",
"template_id":1,
"variables":{
"hello":"there",
"me":"you"
},
"sections":[
{
"name":"Section",
"contents":[
{
"id":1,
"name":"RENAMED!"
}
]
},
{
"name":"section2",
"contents":[
{
"name":"something",
"body":"nothing"
},
{
"id":2,
"name":"I renamed you",
"variables":{
"hello":"i'm amazing"
}
}
]
}
],
"attachments":[
{
"media_id":1
}
]
}
}