Closed eryi closed 8 years ago
Because the wrap-json-params
middleware treats JSON request bodies as a map of parameters. If the request body isn't a JSON object, it can't treat it as a map of parameters.
You'll note that wrap-json-body
will accept any valid JSON data.
I guess the confusing part is that while malformed JSON throws an error, properly formatted non-objects JSON gets silently discarded. Would it be a good idea for wrap-json-params to treat non-objects as malformed and throw errors?
wrap-json-params
works the same way as wrap-params
, in that it only assocs valid parameters.
In general, consider wrap-json-params
as a version of wrap-params
that works with JSON. Most of the time you'll want to use wrap-json-body
instead. wrap-json-params
might even be deprecated in future versions.
On line 48 of json.cli :
The
map?
mysteriously filters out perfectly valid JSON strings and arrays. Why is this so?