Express parses request body with JSON incorrectly
I am sending a JSON object from web client, which looks like this:
{"AudioEncoder":{"Settings":{"1":{"audio_bitrate":"16000"}}}}
And in the request I get from req.body.myvalue:
{"AudioEncoder":{"Settings":[null,{"audio_bitrate":"16000"}]}}
In the Network panel of my browser I see correct value though:
myvalue[AudioEncoder][Settings][1][audio_bitrate]:16000
Error is where I am expecting object with key {1:... but get [null:...
By the information you provide it looks like you're converting your object to url-encoded form data (application/x-www-form-urlencoded), not sending as JSON (application/json). I'd recommend sending your data as JSON instead.
Even if you wanted to send your data as application/x-www-form-urlencoded, I wouldn't consider this a bug since that representation doesn't have any real way to distinguish between objects and arrays.
yea application/x-www-form-urlencoded is pretty sketchy since there's no spec, definitely recommend json as well for more complex stuff like this