I'm using rails 3.4, node 9, and Hapi js 16.5.2
What i'm trying to do is send a nested JSON from a rails app to a hapi js app, but something weird is happening. I am using the Rest-Client request for sending a POST request. the JSON is of the following format:
data = {
time => {
start => "12.11.17",
end => "13.11.17"
},
event => "party"
}
The request is of the following form:
RestClient::Request.new(
:method => :post,
:url => "mynodeserverroute",
:payload => data
).execute
The problem is all the nested elements are sent really weirdly, instead of being of the form:
time: {
start: "12.11.17",
end: "13.11.17"
}
It comes back in the form
"time[start]": "12.11.17",
"time[end]": "13.11.17"
Which makes it challenging to verify later of. What am I doing wrong? I tried adding the following to the request:
:header => {
:content_type => :json,
:accept => :json
}
but that didn't help as well. Is there a different method to send a JSON via rails?
Aucun commentaire:
Enregistrer un commentaire