I have the following Json request
{
"id": "4",
"imp": [{
"id": "1",
"banner": {
"w": 300,
"h": 250,
"mimes": [
"image/jpg",
"image/gif",
"text/html",
"image/png",
"image/jpeg",
"application/javascript"
],
"hmin": 250
},
"bidfloor": 0.01,
"bidfloorcur": "USD",
},
{
"id": "2",
"banner": {
"w": 300,
"h": 250,
"mimes": [
"image/jpg",
"image/gif",
"text/html",
"image/png",
"image/jpeg",
"application/javascript"
],
"hmin": 250
},
"bidfloor": 0.033,
"bidfloorcur": "USD",
},],
"tmax": 2000,
}
I want to receive this json request and update some of its field and return it
I tried the following code
def index(conn, params) do
if (!params) do
Plug.Conn.send_resp(204)
else
IO.puts "RRR"
params=put_in(params["tmax"], params["tmax"]- 20)
params=put_in(Enum.at(params["imp"],0)["bidfloor"], Enum.at(params["imp"],0)["bidfloor"]+2)
Enum.each params["imp"], fn x ->
IO.inspect x
params=put_in(x["bidfloor"], x["bidfloor"]+20)
end
json(conn, params)
end
but this line
params=put_in(Enum.at(params["imp"],0)["bidfloor"], Enum.at(params["imp"],0)["bidfloor"]+2)
is only returning part of the request (the “imp” part)
what should I do?