Closed acerberus closed 7 years ago
Hi @acerberus
Plug doesn't handle list parameter.
With curl -XPOST 127.0.0.1:8828/list_test -H 'Content-Type: application/json' -d '[1, 2, 3]'
, I get %{"_json" => [1, 2, 3]}
when run conn.params
, so the name of unnamed parameter lists
is _json
, you can handle it with such code:
params do
requires :_json, type: List do
YOUR NESTED PARAMETERS
end
end
and use it by params[:_json]
Hi @falood, works like a charm. Thanks for the quick response and the good work on maru.
Hi,
I was wondering if it is possible to define an unnamed parameter list. Something in the following style:
The idea is to send json arrays, for example;
[ {"foo" : "foobar", "bar": "foobar"}, ...]
As far as I can tell, all parameters have to be named, which usually makes sense, except for the above use case. Any help or pointers are much appreciated.