Open bjornwein opened 8 years ago
@bjornax many thanks for creating the issue. PR on its way.
Converting JSON (and other serialized data) to HMV seems like a bad move: https://github.com/miyagawa/Hash-MultiValue/issues/11
@bjornax I'd suggest as a workaround until we've got this nailed down is to NOT use body_parameters
but grab your data using the good old params
keyword:
my $data = from_json(params('body'));
@SysPete ok. Thank you for the impressively quick initial response. A temporary workaround is no problem for me as I'm still prototyping. Looking forward to a permanent solution when ready.
I noticed that for some JSON body parameter schemas, arrays are sometimes simply removed when deserialized and stored in request->body_request() For example, this JSON body parameter:
will be parsed into this in a route:
Notice that the "foo" field is no longer an array after the deserialization, but the "foobar" field is as expected. I can reproduce this in both 0.202000 and 0.203000.
I tracked it down to the use of Hash::MultiValue->from_mixed(), and with this naive patch it works as expected for me:
I expect my "solution" to break more than it fixes, but I hope that you experts can come up with a better solution.